Home > Backend Development > PHP Tutorial > About page 502 troubleshooting, page 502 troubleshooting_PHP tutorial

About page 502 troubleshooting, page 502 troubleshooting_PHP tutorial

WBOY
Release: 2016-07-12 08:56:26
Original
2060 people have browsed it

关于页面502的一次排查,页面502排查

一、场景: 系统 Deepin 15;php 5.5.33;nginx 1.9.9

二、状况: 简单的页面输出正常(比如 phpinfo();),跑公司的任何一个项目,均502

三、排查

1、查询各种日志,包括 nginx.error.log、php_error.log、php-fpm.error.log,找到php-fpm报错如下

[22-Mar-2016 11:06:32] WARNING: [pool www] child 3665 exited with code 127 after 24.657496<span> seconds from start
[22-Mar-2016 11:06:32] NOTICE: [pool www] child 3676 started</span>
Copy after login

2、最开始以为是由php-fpm进程数不足引起,便对php-fpm.ini做出如下修改

(这一步和网上很多的解决方案相同,但是没有效果)

pm.max_children = 20<span>
pm.start_servers = 10<span>
pm.min_spare_servers = 10<span>
pm.max_spare_servers = 20<span>
pm.process_idle_timeout =<span> 10s
pm.max_requests = 500</span></span></span></span></span>
Copy after login

3、经过大量查询,有说是Linux文件句柄数不足

(忘记保留url和改动的地方,经过一番折腾也没有效果)

4、回归 php-fpm.error.log,通过 exited with code 127 查到

(http://www.faqs.org/docs/abs/HTML/exitcodes.html)

5、基于上一步才想起用 strace 来跟踪 php-fpm进程,方法分两种

(其实这一步早该尝试,Rango http://rango.swoole.com/archives/340)

5.1、把php-fpm的进程数限制设置为1,然后直接 strace -p 123456 进行跟踪单个进程

5.2、直接使用下面的命令批量跟踪进程

ps -ef | grep fpm | awk '{print "-p " $2}' | xargs strace
Copy after login

由于出问题的是自己的机子,没有其他人访问,所以使用第二个方法进行跟踪,部分结果如下

[pid  6744] fstat(5, {st_mode=S_IFREG|0644, st_size=5016, ...}) = 0<span>
[pid  6744] mmap(NULL, 5016, PROT_READ, MAP_SHARED, 5, 0) = 0x7f132588f000<span>
[pid  6744] munmap(0x7f132588f000, 5016) = 0<span>
[pid  6744] close(5)                    = 0<span>
[pid  6744] writev(2, [{"php-fpm: pool www", 17}, {": ", 2}, {"symbol lookup error", 19}, {": ", 2}, {"/usr/local/php/lib/php/extension"..., 71}, {": ", 2}, {"undefined symbol: mmc_queue_pop", 31}, {"", 0}, {"", 0}, {"\n", 1}], 10) = 145<span>
[pid  6744] exit_group(127)             = ?</span></span></span></span></span>
Copy after login

定为到报错信息 undefined symbol: mmc_queue_pop

6、既然是 memcache 扩展报错,便开始折腾,从基本编译命令开始

cd /data/memcache-3.0.8/<br />/usr/local/php/bin/<span>phpize                                                                                                
./configure --with-php-config=/usr/local/php/bin/php-<span>config<br />#sudo make clean #但存在多次编译安装时,最好都进行清除                                         
sudo make
sudo make install</span></span>
Copy after login

仔细查找,发现 ./configure 报了个 WARNING

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
Copy after login

     于是开始补齐 re2c,并重新编译 memcache,重启 php-fpm,然而依旧报错

7、最后找到一篇文章,提及“我的memcache原来是从官网下的beta版,重新下载一个stable版本编译安装一下问题就OK了”

     而我用的正是beta版的 memcache-3.0.8,于是马上下载stable版的 memcache-2.2.7 重新编译,问题成功解决。

     (http://www.phpjiayuan.com/77/433.html)

四、特别申明:此文章所提及的东西,部分来自某开发群的大神们,在此鸣谢!

五、后记:此问题是不是只存在于 php 5.5.33 + memcache-3.0.8(beta),有待后续跟进

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1112056.htmlTechArticle关于页面502的一次排查,页面502排查 一、场景:系统Deepin 15;php 5.5.33;nginx 1.9.9 二、状况: 简单的页面输出正常(比如 phpinfo();),跑公...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template