Although through Nginx Accesslog can record user access to an interface or the time spent on a webpage, but can not be clearly traced to the specific location or the function is slow, so through the php-fpm slow log, Slowlog setting allows us to see which PHP processes are too slow to cause problems with the site
Php-fpm.conf has a parameter in the configuration file request_slowlog_timeout is described in this way
for which 'slowlog'file'0s'off '0= 0
When Request_slowlog_timeout is set to a specific second, Request_slowlog_timeout = 1, indicating which script execution time is greater than 1 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.
file for if= log/$pool. Log.slow
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.
[ --may- . -: -:Panax Notoginseng] Notice:child16683Stopped fortracing[ --may- . -: -:Panax Notoginseng] Notice:about to trace16683[ --may- . -: -:Panax Notoginseng] Notice:finished Trace of16683[ --may- . -: -:Panax Notoginseng] WARNING: [Pool www] Child16720, script'/data/webapps/test/public/index.php'(Request:"post/index.php/test/test/") Executing too slow (1.204894SEC), logging
Request_slowlog_timeout and Slowlog need to be set at the same time, the request_slowlog_timeout need to turn on Slowlog, slow log path needs to be created manually
To turn on the php-fpm slow log step specifically:
cd/apps/phpvi /apps/php/etc/php-fpm.conf Remove request_slowlog_timeout, slowlog prefix semicolon ' ; ', set request_slowlog_timeout =1;: Wq save exit Create slow Log directory mkdir -p/apps/php/etc/ Log restart PHP-fpmkillall php-fpm/apps/php/sbin/php-fpm
Slow log configuration is enabled in PHP-FPM (to detect slow PHP script execution)