Slow log configuration is enabled in Nginx php-fpm (for detecting slow PHP scripts) _nginx

Source: Internet
Author: User
Tags fpm

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.