Install awstats log statistical analysis in Linux

Source: Internet
Author: User
Tags geoip install perl reverse dns maxmind

1. Download and install

Cd/data/software

Wget http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpm

2. Start Configuration

Install the dependency package:

Yum-y install perl-libwww-perl.noarch perl-CPAN

Rpm-ivh awstats-7.0-1.noarch.rpm

Cd/usr/local/awstats/tools

Perl awstats_configure.pl

3. Name the default awstats. model. conf as common. conf.

Cd/etc/awstats

Mv awstats. model. conf common. conf

4. Modify the public configuration, find the object project, remove the # sign, and modify the corresponding path.

LoadPlugin = "decodeutfkeys"

LoadPlugin = "geoip GEOIP_STANDARD/usr/local/awstats/plugins/GeoIP. dat"

LoadPlugin = "geoip_city_maxmind GEOIP_STANDARD/usr/local/awstats/plugins/GeoLiteCity. dat"

LoadPlugin = "decodeutfkeys"

DNSLookup = 0

Disable reverse dns lookup (DNSLookup = 0) in the awstats configuration file ).

DNSlookup is used to query the visitor's domain/country information based on the visitor's ip address. Generally, DNS queries are slow, depending on the network environment and system configuration. Disabling DNSlookup will save 99% of the analysis time. In actual testing, 62 m logs (0.3 million records) are analyzed for more than two hours if dnslookup is enabled, and the analysis time when dnslookup is disabled is 1 minute, which greatly shortens the analysis time. The loss of dnslookup is that the visitor's country information cannot be obtained. awstats officially recommends that you use a more precise geoip plug-in to replace dnslookup.

5. Modify the template program

Vi/usr/local/awstats/wwwroot/cgi-bin/awstats. pl

Find $ LIMITFLUSH = 5000

Increase his value by 10 times. The default value of 5000 is 50000, which can effectively increase the speed of statistics (reduce disk I/O) and avoid excessive statistical files caused by monthly summary of data;

6. Add the configuration file naming rule for the statistics site: awstats. sitename. conf

Set the configuration file as follows: the Log Path should be modified according to the name of your server log

Vi awstats.www.yourdomain.com. conf

Input:

Include "common. conf"

LogFile = "/home/logs/www.yourdomain.com/~yyyy-24/~mm-24/access.~yyyy-24?mm-24=dd-24.log"

SiteDomain = "www.yourdomain.com"

HostAliases = "yourdomain.com"

DefaultFile = "index.html"

DirData = "/home/awstats/htdocs"

If the HostAliases parameter is set to "write" or "delete ",

Output directory of the DirData Analysis page, which is the web Access Directory configured for the current nginx or apache

Log files need to be cut and saved every day for Statistics

How to automatically cut: http://blog.csdn.net/zhouzme/article/details/18909185

If the configuration is added, copy cp awstats.www.yourdomain.com. conf awstats.www.anotherdomain.com. conf and modify the domain name.

7. Install the plug-in

Cd/data/software

Wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz

Tar zxvf GeoIP.tar.gz

Cd./GeoIP-1.4.8

./Configure

Make & make install

Wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.40.tar.gz

Tar zxvf Geo-IP-1.40.tar.gz

Cd Geo-IP-1.40

Perl Makefile. PL

If an error occurs: perl Makefile. pl pp = 1

Make & make install

Wget http://search.cpan.org/CPAN/authors/id/ B /BR/BRICAS/Geo-IPfree-1.121660.tar.gz

Tar zxvf Geo-IPfree-1.121660.tar.gz

Cd Geo-IPfree-1.121660

Perl Makefile. PL

Make & make install

Mkdir/usr/local/awstats/plugins

Cd/usr/local/awstats/plugins

Wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

Wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

Gunzip GeoLiteCity.dat.gz

Gunzip GeoIP.dat.gz

8. generate static files

Copy the icon file to the web root directory

Cp/usr/local/awstats/wwwroot/icon // home/awstats/htdocs-rf

/Usr/local/awstats/tools/awstats_buildstaticpages.pl-config = www.yourdomain.com-lang = cn-dir =/home/awstats/htdocs-update

9. Regular generation

Crontab-e

# Awstats

0 0 ***/usr/local/awstats/tools/awstats_buildstaticpages.pl-config = www.yourdomain.com-lang = cn-dir =/home/awstats/htdocs-update

10. Configure Internet access to the current page

Such as: http://awstats.yourdomain.com/awstats.www.yourdomain.com.html can access

Complete.

Note: Each statistical data is from yesterday, and the data on that day is only available the next day.

 

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.