上游过早关闭FastCGI stdout,同时从上游读取响应头

时间:2016-02-15 13:12:17

标签: php html mysql logging nginx

我突然收到502 Bad gateway错误,我不明白为什么会出现此错误。此错误仅出现在1个单页!! ...

我的Nginx日志中的确切错误是:

 Upstream prematurely closed FastCGI stdout while reading response header from upstream [..] upstream: "fastcgi://unix:/var/run/php5-fpm.sock:"

我试过了:

  • service nginx restart:NOTHING CHANGE
  • service php5-fpm restart:NOTHING CHANGE
  • 重启服务器:NOTHING CHANGE
  • 甚至重启mysql服务:NOTHING CHANGE

我的/var/log/upstart/php5-fpm.log(只有很多通知):

Terminating...
exiting, bye-bye!
fpm is running, pid 9887
ready to handle connections
systemd monitor interval set to 10000ms

这让我疯了,不知道吗?

2 个答案:

答案 0 :(得分:0)

我对服务器nginx配置执行了以下操作:

   client_body_timeout 1200;
   client_header_timeout 600;

并将zend_extension添加到php fpm php.ini:

zend_extension = xdebug.so

答案 1 :(得分:0)

尝试在源文件中include <fcgi_stdio.h>。 刚才我发生了此错误,然后在我的include <fcgi_stdio.h>文件中添加了c,这是我的代码。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcgi_config.h>
#include <fcgi_stdio.h>

int main()
{
    int count = 0;
    while(FCGI_Accept() >= 0)
    {
        printf("content-type:text/html\r\n");
        printf("\r\n");
        printf("<title>Fast CGI Hello</title>");
        printf("<h1>fast CGI hello</h1>");

        printf("Request number %d running on host<i>%s</i>\n",++count,getenv("SERVER_NAME"));
    }

    return 0;
}