Nginx + PHP-FPM 502 错误网关
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3616191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Nginx + PHP-FPM 502 Bad Gateway
提问by Andreas
I am getting a 502 Bad Gateway
from Nginx on a line of PHP code that is working fine in other places of my program ($this->provider = new OAuthProvider();
), and that have worked fine before. This is the message I get in the Nginx error log for each 502:
我502 Bad Gateway
从 Nginx 获得了一行 PHP 代码,该代码在我程序的其他地方 ( $this->provider = new OAuthProvider();
) 运行良好,并且之前运行良好。这是我在 Nginx 错误日志中为每个 502 得到的消息:
recv() failed (104: Connection reset by peer) while reading response header from upstream
从上游读取响应标头时,recv() 失败(104:对等方重置连接)
In the PHP-FPM log there is a warning for each 502:
在 PHP-FPM 日志中,每个 502 都有一个警告:
[WARNING] [pool www] child 17427 exited on signal 11 SIGSEGV after 142070.657176 seconds from start
[警告] [pool www] child 17427 在信号 11 SIGSEGV 从开始后 142070.657176 秒退出
After trying a number of changes to the nginx.conf I am stuck and would very much appreciate any pointers of what to do next.
在尝试对 nginx.conf 进行一些更改后,我被卡住了,非常感谢您提供下一步该做什么的任何指示。
I'm running Nginx 0.7.67 and PHP 5.3.2 on Ubuntu 10.04.
我在 Ubuntu 10.04 上运行 Nginx 0.7.67 和 PHP 5.3.2。
采纳答案by Rob Olmos
maybe http://pecl.php.net/bugs/bug.php?id=17689or bug id #18138
也许http://pecl.php.net/bugs/bug.php?id=17689或 bug id #18138
回答by TML
Your PHP process crashed with a segfault ("signal 11 SIGSEGV"), which caused Nginx to see "connection reset by peer" (PHP is the "peer" in this case, and Nginx is telling you "Look, he hung up on me before I could get an answer from him").
您的 PHP 进程因段错误(“信号 11 SIGSEGV”)而崩溃,这导致 Nginx 看到“连接重置由对等方”(在这种情况下,PHP 是“对等方”,Nginx 告诉您“看,他挂断了我在我得到他的答复之前”)。
Check out the PHP Bug database page on how to report a bug someone will want to fixto find out how to get a backtrace of the segfault so you can report it.
查看 PHP 错误数据库页面,了解如何报告某人想要修复的错误,以了解如何获取段错误的回溯以便您可以报告它。
回答by metthyn
i had the same problem with APC. so i removed it and installed eaccelerator instead. no problem so far.
我在 APC 上遇到了同样的问题。所以我删除了它并安装了eaccelerator。到目前为止没有问题。
回答by Mickey Mouse
ZendOptimizer + APC + php-fpm 5.2.14 gives constantly reproducible SIGSEGV even on phpinfo();.
ZendOptimizer + APC + php-fpm 5.2.14 即使在 phpinfo(); 上也能提供持续可重现的 SIGSEGV。
回答by nimmen
I had similar problems with nginx/lighttpd + php-fcgi(using spawn-fcgi), do you use any opcode cache for php? What i found quite some time ago is that xcache was causing strange behaviour in php-fcgi, some php-fcgi processes randomly died, i was unable to find any pattern. I would recommend to take a look at apc(or other opcode cache) settings, if you are using any. Right now im using nginx + php-fpm on freebsd and have no problems.
我在使用 nginx/lighttpd + php-fcgi(使用 spawn-fcgi)时遇到了类似的问题,你是否对 php 使用了任何操作码缓存?我前段时间发现 xcache 在 php-fcgi 中引起了奇怪的行为,一些 php-fcgi 进程随机死亡,我找不到任何模式。如果您正在使用任何设置,我建议您查看 apc(或其他操作码缓存)设置。现在我在 freebsd 上使用 nginx + php-fpm 并且没有问题。
回答by Slavikus
Try to switch suhosin off. Sometimes it crashes Apache.
尝试关闭 suhosin。有时它会导致 Apache 崩溃。