A lot of stationmaster turns to NGINX+PHP-FPM after, suffer 500,502 problem to be troubled. When Nginx received the error code, you can determine that the backend php-fpm parsing PHP has some kind of problem, such as execution error, execution timeout.
Php-fpm.conf's configuration file has a parameter request_slowlog_timeout is described in this way
Copy Code code as follows:
; The timeout for serving a only 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, which indicates if which script executes longer than 5 seconds, this script is logged to the slow log file
Request_slowlog_timeout =0 indicates that slow log output is turned off.
Slow log file location default in the log folder in the installation directory of PHP, you can specify by modifying Slowlog = log/$pool. Log.slow parameters.
PHP-FPM Slow Log example, slow log will record the process number, script name, the specific file which line of code which function of the execution time is too long.
Copy Code code 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 be specified for use with ' request_slowlog_timeout '
Request_slowlog_timeout and Slowlog need to be set at the same time, open the request_slowlog_timeout and need to open the Slowlog
Copy Code code 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
Specifically open PHP-FPM slow log steps:
Copy Code code 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 a slow log directory
mkdir Log
Restart PHP-FPM
Kill-int ' Cat Var/run/php-fpm.pid
sbin/php-fpm