|
Many webmasters are troubled by 500,502 issues after switching to nginx+php-fpm. When nginx receives the above error code, it can be determined that there is some kind of problem with the backend php-fpm parsing php, such as execution error or execution timeout. php-fpm.conf has a parameter request_slowlog_timeout described like this - ; The timeout for serving a single request after which a PHP backtrace will 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
Copy codeWhen request_slowlog_timeout is set to a specific second request_slowlog_timeout =5, it means that if a script is executed for more than 5 seconds, the script will be recorded in the slow log file
request_slowlog_timeout =0 means that slow log output is turned off. The slow log file location is in the log folder in the php installation directory by default, and you can specify it by modifying the slowlog = log/$pool.log.slow parameter. php-fpm slow log example, the slow log will record the process number, script name, specific file which line of code, which function is too long to execute. - [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'
Copy coderequest_slowlog_timeout and slowlog need to be set at the same time, and you need to turn on slowlog at the same time as turning on the request_slowlog_timeout - [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)
Copy codeSlow log paths need to be created manually
Specific steps to enable php-fpm slow logging: - cd /usr/local/lnmp/php
- vi etc/php-fpm.conf
- 去掉request_slowlog_timeout 、slowlog的前缀分号';',设置request_slowlog_timeout =5;
- :wq
- 保存退出
- 创建慢日志目录
- mkdir log
- 重启php-fpm
- kill -INT `cat var/run/php-fpm.pid
- sbin/php-fpm
Copy code
|