NGINX出現500錯誤的常見解決
nginx出現500錯誤,不會顯示具體錯誤資訊。要到日志檔案裡面去看,通過yum安裝的nginx的日志檔案位于/var/log/nginx/error.log
(24: Too many open files)
日志檔案裡面出現類似(24: Too many open files)的錯誤資訊,這是說明nginx太過于繁忙,打開檔案的數量超過linux的系統限制。
解決辦法
修改3個檔案
/etc/security/limits.conf
增加
* soft nofile 51200
* hard nofile 65535
修改/etc/pam.d/login
session required /lib/security/pam_limits.so
nginx.conf
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
然後重新開機伺服器 ulimit -n 檢視檔案限制,應該顯示51200
本文轉自 xxl714 51CTO部落格,原文連結:http://blog.51cto.com/dreamgirl1314/968292,如需轉載請自行聯系原作者