zoukankan      html  css  js  c++  java
  • nginx php-fpm启用慢日志slowlog

    php-fpm慢日志slowlog设置可以让我们很好的看见哪些php进程速度太慢而导致的网站问题。

    可以让我们方便的找到问题的所在。

     代码如下
    1 vi /data1/server/php-cgi/etc/php-fpm.conf
    2  
    ; The log file for slow requests
    ; Default Value: not set
    ; Note: slowlog is mandatory if request_slowlog_timeout is set
    slowlog = /data1/log/$pool.log.slow
     
    ; 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 = 1s

    必须同时设置request_slowlog_timeout 0s表示关闭,就是slowlog没有用

    1s表示超过1秒的处理都会被记录。

    看看具体执行慢到多少秒

     代码如下
    1 /data1/server/php-cgi/var/log/php-fpm.log
    2 [19-Apr-2013 12:40:35] WARNING: [pool www] child 29514, script ‘/xx/www/adx/tx/tm.php’ (request: “GET /tx/tm.php”) executing too slow (1.034708 sec), logging


    补充一下不同版本php下开启慢日志教程

    PHP 5.3.3 之前版本设置如下:

     代码如下
    1 The timeout (in seconds) for serving a single request after which the worker process will be terminated
    Should be used when 'max_execution_time' ini option does not stop script execution for some reason
    '0s' means 'off'
    <value name="request_terminate_timeout">10s</value>
    The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
    '0s' means 'off'
    <value name="request_slowlog_timeout">1s</value>
    The log file for slow requests
    <value name="slowlog">logs/slow.log</value>


    PHP 5.3.3 之后版本设置如下:

     代码如下
    1 ; 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 = 1s
    2 ; The log file for slow requests
    ; Default Value: /usr/local/php/log/php-fpm.log.slow
    slowlog = /usr/local/php/log/php-fpm.log.slow
    3 ; The timeout for serving a single request after which the worker process will
    ; be killed. This option should be used when the 'max_execution_time' ini option
    ; does not stop script execution for some reason. A value of '0' means 'off'.
    ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
    ; Default Value: 0
    request_terminate_timeout = 10s

    注:request_terminate_timeout 将执行时间太长的进程直接终止

    request_slowlog_timeout 将执行过慢的文件写入日志

    以后即可根据慢执行日志 /usr/local/php/logs/slow.log 来优化程序文件了!

  • 相关阅读:
    CSS3 背景
    CSS3 边框
    CSS3中的transform变形
    兼容IE与firefox火狐的回车事件(js与jquery)
    JS相关链接
    JS操作DOM元素属性和方法
    用js给html设置style
    JavaScript数学函数(一)
    [JS] 如何清空file input框 [整理]
    未在本地计算机上注册Microsoft.ACE.OLEDB.12.0提供程序(Oledb)
  • 原文地址:https://www.cnblogs.com/xiaoleiel/p/8334730.html
Copyright © 2011-2022 走看看