apache+php site load from time to time high load, but because there are too many sites, too difficult to find out which site is caused by. NGINX+PHP-FPM is good to check, he has a slowlog, can quickly navigate to the failure of the PHP code location, using Xdebug to check the problem is too complex. Writing Mod_log_slow's inspiration comes from MySQL's slowlog. The following content is translated by the official.
Project Address: http://code.google.com/p/modlogslow/
1. Compile and install Mod_log_slow
1) Decompression
Copy Code code as follows:
Tar zxf mod_log_slow-1.0.7.tar.gz
CD Mod_log_slow
Or you can download it from GitHub.
Copy Code code as follows:
git clone git://github.com/yokawasa/mod_log_slow.git
CD Mod_log_slow
2 Open Makefile and modify variable Ap_basedir
Copy Code code as follows:
#vi Makefile
ap_basedir=/to your Apache installation path
# make
# make Install
2. Configure Apache
2.1 Loading Module
Copy Code code as follows:
LoadModule Log_slow_module modules/mod_log_slow.so
2.2 Configuring the virtual host
Copy Code code as follows:
<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\" \ "%{logslo W-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. Reboot
Copy Code code as follows: