Use mod_log_slow slow response request targeting apache

apache + php site load time to time high load, but because of the above sites too much, too difficult to troubleshoot in the end is what caused the site. nginx + php-fpm'd better check, he had a slowlog, you can quickly navigate to the location of php code failure, use xdebug to look into the problem is too complex. Write mod_log_slow inspired by the mysql slowlog. The following translation of the official. 1. compile and install mod_log_slow 1) extracting
tar zxf mod_log_slow-1.0.7.tar.gz
cd mod_log_slow
Or may be detected from the github
git clone git://github.com/yokawasa/mod_log_slow.git
cd mod_log_slow
2) Open Makefile and modify variables ap_basedir
#vi Makefile
 ap_basedir=/改成你的apache安装路径
# make
# make install
Configuring Apache 2.1 Load Module
LoadModule log_slow_module modules/mod_log_slow.so
2.2 virtual host configuration
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /usr/local/apache/htdocs
    ErrorLog logs/error_log

    LogLevel debug
    CustomLog logs/access_log common
    CustomLog logs/transfer_log "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{logslow-id}n\" \"%{logslow-time}n\""

    ## (VirtualHost) mod_log_slow configuration
    LogSlowEnabled On
    LogSlowLongRequestTime 100
    LogSlowFileName /usr/local/apache/logs/slow_log
    LogSlowTimeFormat "[%Y-%m-%d %H:%M:%S]"
    LogSlowBufferedLogs Off
</VirtualHost>
3. Restart
service httpd restart
Project Address: http: //code.google.com/p/modlogslow/ please indicate the source: Use mod_log_slow locate apache slow response request http://www.ttlsa.com/html/2290.html

Reproduced in: https: //my.oschina.net/766/blog/211551

Guess you like

Origin blog.csdn.net/weixin_33724059/article/details/91493186