Many webmasters turn to NGINX+PHP-FPM, suffering from 500,502 of problems. When Nginx receives the above error code, it can be determined that the backend php-fpm parsing php out of some kind of problem, such as execution error, execution timeout.
Php-fpm.conf has a parameter in the configuration file request_slowlog_timeout is described in this way
The code is as follows:
; The timeout for serving a single request after which a PHP backtrace would be
; Dumped to the ' slowlog ' file. A value of ' 0s ' means ' off '.
; Available units:s (econds) (default), M (inutes), H (ours), or D (ays)
; Default value:0
; request_slowlog_timeout = 0
When Request_slowlog_timeout is set to a specific second, Request_slowlog_timeout = 5, indicating which script execution time is greater than 5 seconds, the script is logged to the slow log file
Request_slowlog_timeout =0 indicates that slow log output is turned off.
The slow log file location defaults to the log folder in the PHP installation directory and can be specified by modifying the Slowlog = log/$pool. Log.slow parameter.
PHP-FPM Slow Log example, the slow log will record the process number, the script name, which file which line of code which function execution time is too long.
The code is as follows:
[21-nov-2013 14:30:38] [Pool www] pid 11877
Script_filename =/usr/local/lnmp/nginx/html/www.quancha.cn/www/fyzb.php
[0xb70fb88c] file_get_contents ()/usr/local/lnmp/nginx/html/www.quancha.cn/www/fyzb.php:2
[21-nov-2013 14:15:23] ERROR: [Pool www] ' slowlog ' must is specified for use with ' request_slowlog_timeout '
Request_slowlog_timeout and Slowlog need to be set at the same time, open request_slowlog_timeout and need to turn on Slowlog
The code is as follows:
[21-nov-2013 14:16:27] Error:unable to create or open Slowlog (/usr/local/lnmp/php/log/www.log.slow): No such file or directory (2)
Slow log paths need to be created manually
To turn on the php-fpm slow log step specifically:
The code is as follows:
cd/usr/local/lnmp/php
VI etc/php-fpm.conf
Remove request_slowlog_timeout, slowlog prefix semicolon '; ', set request_slowlog_timeout = 5;
: Wq
Save exit
Create slow Log directory
mkdir Log
Restart PHP-FPM
Kill-int ' Cat Var/run/php-fpm.pid
sbin/php-fpm
This article is from the "Steven Never give Up" blog, please be sure to keep this source http://wsw26.blog.51cto.com/1442148/1769366
Enable slow log configuration in Nginx php-fpm (used to detect slow PHP scripts)