php502故障处理

Posted oldxulinux

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php502故障处理相关的知识,希望对你有一定的参考价值。

一次打开网站,发现502,第一反应肯定是php-fpm没启动,尝试启动还是502.

1.首先查询nginx日志发现如下连接PHP失败:


2016/07/29 15:56:04 [error] 23760#0: *186 connect() failed (111: Connection refused) while connecting to upstream, client:

11.10.8.252.18, server: xuliangwei.com request: "GET /index.php?route=rest/crontab HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xuliangwei.com"

2.通过dmesg 查询至如下:


[6819070.815161]init: php5-fpm main process ended, respawning

[6819070.861943]init: php5-fpm main process (25401) terminated with status 78

[6819070.861955]init: php5-fpm main process ended, respawning

[6819070.910152]init: php5-fpm main process (25409) terminated with status 78

3.通过php-fpm检测配置文件


[email protected]:/etc/php5/fpm/pool.d# /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf

[29-Jul-2016 15:57:14] ERROR: [/etc/php5/fpm/php-fpm.conf:27] unknown entry ‘catch_workers_output‘

[29-Jul-2016 15:57:14] ERROR: failed to load configuration file ‘/etc/php5/fpm/php-fpm.conf‘

[29-Jul-2016 15:57:14] ERROR: FPM initialization failed

4.注释catch_workers_output


[email protected]:/etc/php5/fpm/pool.d# vim /etc/php5/fpm/php-fpm.conf +27

[email protected]:/etc/php5/fpm/pool.d# service php5-fpm start

php5-fpm start/running, process 25545

5.启动成功后,网站已正常访问


[email protected]:/etc/php5/fpm/pool.d# ps aux|grep php

root 25545 0.6 0.1 342748 18812 ? Ss 15:58 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)

ubuntu 25548 0.0 0.0 342748 5644 ? S 15:58 0:00 php-fpm: pool www

ubuntu 25549 0.0 0.0 342748 5644 ? S 15:58 0:00 php-fpm: pool www

ubuntu 25550 0.0 0.0 342748 5644 ? S 15:58 0:00 php-fpm: pool www

ubuntu 25551 0.0 0.0 342748 5644 ? S 15:58 0:00 php-fpm: pool www

ubuntu 25552 0.0 0.0 342748 5644 ? S 15:58 0:00 php-fpm: pool www

6.谷歌给出的解决方案有以下2种:

1.php-fpm没有运行

执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可

netstat -ant | grep 9000

2.php-fpm队列满了

php-fpm.conf配置文件pm.max_children修改大一点,重启php-fpm并观察日志情况

以上是关于php502故障处理的主要内容,如果未能解决你的问题,请参考以下文章

莫斯科保卫战之PHP-502 Bad Gateway

PHP出现502解决方案

502 Bad Gateway深究

Nginx502状态码处理

nginx 502 Bad Gateway 错误解决办法

LNMP环境出现502 Bad Gateway报错