Installation and configuration of Apache Log Analysis Tool Awstats

Source: Internet
Author: User
Tags apache access log apache log

These days, due to the large differences in the statistical data of several different traffic statistical tools, I thought that we should analyze the apache access log, where the data should be the most authoritative. At the beginning, I wrote a simple analysis tool for emergency response and collected some simple data. The open-source Awstats should be a widely used and fully functional tool.

The installation and configuration of Awstats are quite simple, but I still make some detours. The most painful lesson is:It is best to configure it by default.. The following describes the installation and configuration processes. First, let's talk about the environment: 64-bit CentOS 5.6 + Apache Httpd 2.2

1. Configure the Apache log output mode.


By default, apache's access. log will be compressed to a certain size, and some old ones will be deleted. No access is found in the Apache document.
For details about log management, I hope you will not be able to give me any suggestions. Here, I configure a file every day for further analysis and backup. Open httpd. conf and find access
Location of log configuration, Set

CustomLog logs/access_log common

Change

CustomLog "|/usr/sbin/rotatelogs/var/log/httpd/access_log. % Y % m % d 86400" combined

Rotatelogs is a log tool provided by Apache.
Rotatelogs to find the path of the tool. In another change, change the log Content from common to combined, so that the log contains more information.
Required by Awstats. If the log configuration is in Virtual Hosts, you can also modify it.

After modification, restart the httpd service and you will see a log file similar to access_log.20151120.12 is generated under/var/log/httpd.

2. Install Awstats

First download the Awstats installation package: awstats-7.0.tar.gz, you can also find the appropriate installation file on the download page.

] # Wget http://prdownloads.sourceforge.net/awstats/awstats-7.0.tar.gz

Awstats-7.0.tar.gz] # tar xzvf

] # Music awstats-7.0/var/

You can follow the Awstats official guide to install the SDK at http://awstats.sourceforge.net/docs/awstats_setup.html. Note the following:

(1) When you ask about the apache configuration file path, you need to write it to the actual apache configuration file path in the current environment. For example, my path is/etc/httpd/conf/httpd. conf.

(2) When querying the path where the Awstats configuration file is stored, you must use the default path. Otherwise, unexpected troubles may occur.

(3) when creating an Awstats configuration file, you will be asked about the name of the configuration file. In fact, this is the time to ask which domain name of the log to be analyzed, for example, your website is www.mysite.com, enter www.mysite.com.

During the installation process, I have always been "yes. At the end of installation, a new directory named awstats www.mysite.com. conf is generated under/etc.

Next, enable httpd. conf and find that some Awstats-related configurations are added at the bottom.

Create a file named awstats under/var/lib to store the data file generated after log analysis.

3. Configure Awstats


After the installation is complete, you need to perform a simple configuration to start using Awstats. Open the configuration file generated above
Awstats.www.mysite.com. conf. Find the LogFile and change it to the path of the actual log file. Note that, in the first step
The configuration here is:

LogFile =/var/log/httpd/access_log. % YYYY-0 % MM-% DD

Indicates that the latest log file is analyzed. For details about this configuration, refer to the detailed explanation in its annotations.

4. Verify Installation

After the configuration is complete, perform the following verification:

] # Cd/var/awstats/wwwroot/cgi-bin

] # Perl awstats. pl-config = www.mysite.com-update

If you strictly follow the above steps, there should be no problem with this step. You can see the output similar to the following:

Create/Update database for config "/etc/awstats/awstats.www.mysite.com. conf" by AWStats version 7.0 (build 1.971)

> From data in log file "/var/log/httpd/access_log.20151120.11 "...

Phase 1: First bypass old records, searching new record...

Direct access after last parsed record (after line 545194)

Jumped lines in file: 545194

Found 545194 already parsed records.

Parsed lines in file: 1677

Found 0 dropped records,

Found 0 comments,

Found 0 blank records,

Found 0 successfully upted records,

Found 0 old records,

Found 1677 new qualified records.

For the sake of security, I did not open the update link on the webpage, but configured the crontab to run the above program every 10 minutes: */10 * root cd/var/awstats/wwwroot/cgi-bin/; perl awstats. pl-config = www.mysite.com-update. On the page, you can see the statistical results refreshed every 10 minutes. 5. Install the IP address conversion plug-inIn the Awstats statistical report, the actual address corresponding to the IP address is displayed, which needs to be implemented through the plug-in. The more common method on the Internet is to use QQWry. dat. However, it takes a long time to find this plug-in, because many places can only download the IP database, rather than the plug-in. You can download an IP database at http://www.cz88.net/fox/ipdat.shtml. Note: here we download an ext Installation File. After installation, there will be a qqwry. dat file, which is the ip database to be used. This IP database is updated frequently, so we need to keep it updated. Plug-in-related files can be passed through: Under the http://blogimg.chinaunix.net/blog/upfile/070103141422.rar
). After decompression, there are three files: qqhostinfo. pm, qqwry. pl, and QQWry. Dat. The first one is the plug-in file.
The second is the real perl program for execution and conversion, and the third is the database. You can use the latest database above to overwrite this. Copy the three files to/var/awstats.
/Wwwroot/cgi-bin/plugins/directory, and make the following changes:] # chmod 755 qqhostinfo. pm] # vim qqwry. pl. /QQWry. change Dat to/var/awstats/wwwroot/cgi-bin/plugins/qqwry. dat. Edit Awstats configuration file awstats.www.mysite.com. conf, find # LoadPlugin = "hostinfo" and add a new line LoadPlugin = "qqhostinfo". After completing all the preceding steps, you can see the statistics on the web page. Chinese may be garbled. You only need to set the browser language to Chinese.

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.