修改配置解决Nginx服务器中常见的上传与连接错误

时间:2022-06-25 13:39:14

nginx上传错误413 Request Entity Too Large
默认情况下使用nginx反向代理上传超过2MB的文件,会报错413 Request Entity Too Large,解决这个方法很简单,修改配置client_max_body_size值即可
修改nginx.conf

?
1
2
#cat /usr/local/nginx-1.7.0/conf/nginx.conf | grep client_max_body_size
 client_max_body_size 10M;

如果需要上传更大的文件,那么client_max_body_size改成更大的值即可,这边改成了10MB
重启nginx

?
1
# /usr/local/nginx-1.7.0/sbin/nginx -s reload


connect() failed (111: Connection refused) while connecting to upstream解决
有时候nginx运行很正常,但是会发现错误日志中依旧有报错connect() failed (111: Connection refused) while connecting to upstream.
一般情况下我们的upstream都是fastcgi://127.0.0.1:9000. 造成这个问题的原因大致有两个
 1.php-fpm没有运行
执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可

?
1
netstat -ant | grep 9000

 
2.php-fpm队列满了
php-fpm.conf配置文件pm.max_children修改大一点,重启php-fpm并观察日志情况