Bad Gateway!

The proxy server received an invalid response from an upstream server.

If you think this is a server error, please contact the webmaster.

php-cgi进程数不够用、php执行时间长、或者是php-cgi进程死掉,都会出现502错误.

solution:

  • KeepAliveTimeout 15
  • TimeOut 300 (required)
  • http
    {
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    } (For fastcgi)
  • max_execution_time 300 (php.ini)

netstat -anpo | grep “php-cgi” | wc -l 查看当前的PHP FastCGI进程数是否够用.如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”,那么,说明“FastCGI进程数”不够用,需要增大。