我的项目中某些页面申请时,页面上啥错都没有,然而network里报500 Internal Server Error谬误的解决办法

接客户反馈,公司一个正在运行的我的项目中某些页面会有谬误,然而没有错误信息,通过查看network发现,nginx报500 Internal Server Error谬误,查看nginx日志发现,日志中含有大量的 socket() failed (24: Too many open files) while connecting to upstream错误信息,如下图所示:

通过查问linux下文件句柄可知:

ulimit -n1024

其零碎的文件句柄为1024,过于小,所以通过一下形式批改

vi /etc/security/limits.conf在文件末减少# 配置nginx用户文件限度nginx soft nofile 65535nginx hard nofile 65535## # 配置所有用户文件限度soft nofile 65535hard nofile 65535同时vi /etc/sysctl.conf开端增加fs.file-max=65535

重新启动,在应用ulimit -n查看的数曾经是65535,但因为须要重启服务器,故临时在终端应用如下命令解决

ulimit -n 65535

须要同时在nginx的配置文件中配置

vi /etc/nginx/nginx.confworker_rlimit_nofile 65535;events {worker_connections 65535;} 

即可解决此问题