Use Mod_log_slow analysis in Apache to respond to slow requests _linux

Source: Internet
Author: User

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:
Service httpd Restart

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.