C语言 c++ php mysql nginx linux lnmp lamp lanmp memcache redis 面试 笔记 ppt 设计模式 问题 远程连接

502 bad gateway 可能的错误原因

 

1、PHP程序的执行时间超过了Nginx的等待时间,可以适当增加nginx.conf配置文件中FastCGI的timeout时间

#http代码段中增加
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;

2、header 头信息过大

3、FastCGI进程数不够用增大 php-fpm.conf 中的 max_children max_requests 值

4、各种超时

nginx 中的  fastcgi_connect_timeout 300; fastcgi_send_timeout 300 :fastcgi_read_timeout 300; keepalive_timeout ; 
php-fpm中的 request_terminate_timeout
php.ini中的 max_execution_time

5、php-fpm.conf  max_requests  每个children最多处理多少个请求后便会被关闭 

在大量处理请求下,如果该值设置过小会导致children频繁的自杀和建立而浪费 大量时间,若所有的children差不多都在这个时候自杀,则重建前将没有children响应请求,于是出现502

 

posted on 2014-04-11 15:16  思齐_  阅读(2506)  评论(0编辑  收藏  举报