修改配置解决Nginx服务器中常见的上传与连接错误
nginx上传错误413RequestEntityTooLarge
默认情况下使用nginx反向代理上传超过2MB的文件,会报错413RequestEntityTooLarge,解决这个方法很简单,修改配置client_max_body_size值即可
修改nginx.conf
#cat/usr/local/nginx-1.7.0/conf/nginx.conf|grepclient_max_body_size client_max_body_size10M;
如果需要上传更大的文件,那么client_max_body_size改成更大的值即可,这边改成了10MB
重启nginx
#/usr/local/nginx-1.7.0/sbin/nginx-sreload
connect()failed(111:Connectionrefused)whileconnectingtoupstream解决
有时候nginx运行很正常,但是会发现错误日志中依旧有报错connect()failed(111:Connectionrefused)whileconnectingtoupstream.
一般情况下我们的upstream都是fastcgi://127.0.0.1:9000.造成这个问题的原因大致有两个
1.php-fpm没有运行
执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可
netstat-ant|grep9000
2.php-fpm队列满了
php-fpm.conf配置文件pm.max_children修改大一点,重启php-fpm并观察日志情况