This article mainly describes the Nginx php-fpm to enable slow log configuration, php-fpm slow log slowlog settings can let us very well see which PHP process is too slow to cause the site problems, can let us conveniently find the problem, the need for friends can refer to the following:
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.
One of the parameters in the php-fpm.conf configuration file is described in Request_slowlog_timeout:
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.
Code:
Vi/usr/local/php/etc/php-fpm.conf
Request_slowlog_timeout =5
Slowlog = log/$pool. Log.slow
The log is guaranteed to exist:/usr/locla/php/logs below
PHP Slow Log