解决Nginx + PHP(FastCGI)遇到的502 Bad Gateway错误(zt)
解决Nginx + PHP(FastCGI)遇到的502 Bad Gateway错误(zt)[文章作者:张宴 本文版本:v1.0 转载请注明原文链接:http://blog.s135.com/read.php/361.htm]
昨日,迅雷的朋友问我,他们将迅雷在线(http://www.xunlei.com/)的Web服务器换成Nginx 0.6.31+ PHP 4.4.7(FastCGI)后,有时候访问会出现“502 Bad Gateway”错误,如何解决。
我让按照以下两个步骤去解决,最后在第2步中将FastCGI的timeout时间增加为300,问题解决:
PS:比较羡慕迅雷的Web服务器,16G内存。
1、查看当前的PHP FastCGI进程数是否够用:
netstat -anpo | grep "php-cgi" | wc -l
如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”,那么,说明“FastCGI进程数”不够用,需要增大。
2、部分PHP程序的执行时间超过了Nginx的等待时间,可以适当增加nginx.conf配置文件中FastCGI的timeout时间,例如:
......
http
{
......
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
......
}
...... 单纯增加 超时时间 如果在并发两高的网站 对于服务器性能来说无疑是增加考验 可以肯定的告诉你,这没用!
运维群:168572651
欢迎各位新手加入,一起学习集群一起学习运维 #######################修改nginx.conf配置文件:
fastcgi_passunix:/tmp/php-cgi.sock;
改为:
fastcgi_pass127.0.0.1:9000;
第二步,修改php-fpm.conf配置文件:
<value name="listen_address">/tmp/php-cgi.sock</value>
改为
<value name="listen_address">127.0.0.1:9000</value>
第三步,依次重启Nginx和php-fpm
nginx 重启:
/usr/local/nginx/sbin/nginx -t/usr/local/nginx/sbin/nginx -s reload
php-fpm重启:
/usr/local/php/sbin/php-fpm restart
现在试试还有没有502错误呢 LS的做法毫无意义
还是会有的 这个是不可行的
页:
[1]