2018-03-05
NGINX-500错误分析
nginx 评论:0 浏览:106

转载请注明出处:https://oldnoop.tech/c/144.html

too many open files错误

访问量大的时候,由于系统资源限制,而不能打开过多的文件
打开nginx错误日志(/usr/local/nginx/logs/error.log)
查看是否报too many open files错误
 

错误解决

centos5/centos6系统

修改limits.conf

打开/etc/security/limits.conf
修改 limits.conf文件,加上下面两句命令
* soft nofile 65535
* hard nofile 65535
 

修改sysctl.conf

vi /etc/sysctl.conf
fs.file-max=65535 

修改nginx.conf

打开/usr/local/nginx/conf/nginx.conf,
在worker_processes的下面增加一行配置
worker_rlimit_nofile 65535;

重启nginx

硬盘容量问题

使用 df -k 查看硬盘空间是否满了。清理硬盘空间就可以解决500错误。

nginx如果开启了access log,在不需要的情况下,最好关闭access log。access log会占用大量硬盘空间

nginx配置文件错误 

nginx如果配置文件有语法错误,启动的时候就会提示。
当配置rewrite的时候,有些规则处理不当会出现500错误,请仔细检查nginx配置的rewrite规则。
如果配置文件里有些变量设置不当,也会出现500错误,比如引用了一个没有值的变量
 

后端服务器错误

比如NGINX+ tomcat集群,tomcat报出的500错误



  • 转载请注明出处:https://oldnoop.tech/c/144.html

Copyright © 2018 oldnoop.tech. All Rights Reserved

鄂ICP备2023022735号-1