


About page 502 troubleshooting, page 502 troubleshooting_PHP tutorial
关于页面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>
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>
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
由于出问题的是自己的机子,没有其他人访问,所以使用第二个方法进行跟踪,部分结果如下
[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>
定为到报错信息 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>
仔细查找,发现 ./configure 报了个 WARNING
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
于是开始补齐 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),有待后续跟进

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor