How to Install and Configure Awstats on CentOS 6.3

Share this Article :

AWStats is short for Advanced Web Statistics it’s an powerful open source tool that generates advanced websites statistics, graphically and provides you with detailed statistics regarding visitors to your web site. AWStats suitable for analyzing data from Internet services such as web, streaming media, mail and FTP servers that shows you the statistics including visits, unique visitors, pages, hits, rush hours, os, browsers, search engines, keywords, robots visits, broken links and more.

1. Install Awstats using yum command :

[[email protected] ~]# yum --enablerepo=rpmforge install awstats -y

Examples :

[[email protected] ~]# yum --enablerepo=rpmforge install awstats -y
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: ossm.utm.my
 * extras: ossm.utm.my
 * rpmforge: mirror.oscc.org.my
 * updates: ossm.utm.my
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package awstats.noarch 0:7.0-2.el6.rf will be installed
--> Processing Dependency: perl(Geo::IP) for package: awstats-7.0-2.el6.rf.noarch
--> Processing Dependency: perl(LWP::UserAgent) for package: awstats-7.0-2.el6.rf.noarch
--> Running transaction check
---> Package perl-Geo-IP.i686 0:1.38-1.el6.rf will be installed
--> Processing Dependency: libGeoIP.so.1 for package: perl-Geo-IP-1.38-1.el6.rf.i686
---> Package perl-Test-Mock-LWP.noarch 0:0.05-1.el6.rf will be installed
--> Processing Dependency: perl(Test::MockObject) for package: perl-Test-Mock-LWP-0.05-1.el6.rf.noarch
--> Running transaction check
---> Package geoip.i686 0:1.4.6-1.el6.rf will be installed
---> Package perl-Test-MockObject.noarch 0:1.09-3.1.el6 will be installed
--> Processing Dependency: perl(UNIVERSAL::isa) for package: perl-Test-MockObject-1.09-3.1.el6.noarch
--> Processing Dependency: perl(UNIVERSAL::can) for package: perl-Test-MockObject-1.09-3.1.el6.noarch
--> Processing Dependency: perl(Test::Builder) for package: perl-Test-MockObject-1.09-3.1.el6.noarch
--> Running transaction check
---> Package perl-Test-Simple.i686 0:0.92-127.el6 will be installed
--> Processing Dependency: perl-devel for package: perl-Test-Simple-0.92-127.el6.i686
---> Package perl-UNIVERSAL-can.noarch 0:1.15-1.el6 will be installed
---> Package perl-UNIVERSAL-isa.noarch 0:1.03-1.el6 will be installed
--> Running transaction check
---> Package perl-devel.i686 4:5.10.1-127.el6 will be installed
--> Processing Dependency: perl(ExtUtils::ParseXS) for package: 4:perl-devel-5.10.1-127.el6.i686
--> Processing Dependency: perl(ExtUtils::MakeMaker) for package: 4:perl-devel-5.10.1-127.el6.i686
--> Processing Dependency: perl(ExtUtils::Installed) for package: 4:perl-devel-5.10.1-127.el6.i686
--> Running transaction check
---> Package perl-ExtUtils-MakeMaker.i686 0:6.55-127.el6 will be installed
--> Processing Dependency: perl(Test::Harness) for package: perl-ExtUtils-MakeMaker-6.55-127.el6.i686
---> Package perl-ExtUtils-ParseXS.i686 1:2.2003.0-127.el6 will be installed
--> Running transaction check
---> Package perl-Test-Harness.i686 0:3.17-127.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                         Arch           Version                      Repository        Size
====================================================================================================
Installing:
 awstats                         noarch         7.0-2.el6.rf                 rpmforge         1.1 M
Installing for dependencies:
 geoip                           i686           1.4.6-1.el6.rf               rpmforge         830 k
 perl-ExtUtils-MakeMaker         i686           6.55-127.el6                 base             291 k
 perl-ExtUtils-ParseXS           i686           1:2.2003.0-127.el6           base              43 k
 perl-Geo-IP                     i686           1.38-1.el6.rf                rpmforge         109 k
 perl-Test-Harness               i686           3.17-127.el6                 base             229 k
 perl-Test-Mock-LWP              noarch         0.05-1.el6.rf                rpmforge          18 k
 perl-Test-MockObject            noarch         1.09-3.1.el6                 base              31 k
 perl-Test-Simple                i686           0.92-127.el6                 base             110 k
 perl-UNIVERSAL-can              noarch         1.15-1.el6                   base              12 k
 perl-UNIVERSAL-isa              noarch         1.03-1.el6                   base              11 k
 perl-devel                      i686           4:5.10.1-127.el6             base             421 k

Transaction Summary
====================================================================================================
Install      12 Package(s)

Total download size: 3.2 M
Installed size: 8.6 M
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 3.2 M
(1/12): awstats-7.0-2.el6.rf.noarch.rpm                                      | 1.1 MB     00:47
(2/12): geoip-1.4.6-1.el6.rf.i686.rpm                                        | 830 kB     00:34
http://ossm.utm.my/centos/6.3/os/i386/Packages/perl-ExtUtils-MakeMaker-6.55-127.el6.i686.rpm: [Errno 12] Timeout on http://ossm.utm.my/centos/6.3/os/i386/Packages/perl-ExtUtils-MakeMaker-6.55-127.el6.i686.rpm: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
Trying other mirror.
(3/12): perl-ExtUtils-MakeMaker-6.55-127.el6.i686.rpm                        | 291 kB     00:05
(4/12): perl-ExtUtils-ParseXS-2.2003.0-127.el6.i686.rpm                      |  43 kB     00:00
(5/12): perl-Geo-IP-1.38-1.el6.rf.i686.rpm                                   | 109 kB     00:02
(6/12): perl-Test-Harness-3.17-127.el6.i686.rpm                              | 229 kB     00:04
(7/12): perl-Test-Mock-LWP-0.05-1.el6.rf.noarch.rpm                          |  18 kB     00:00
(8/12): perl-Test-MockObject-1.09-3.1.el6.noarch.rpm                         |  31 kB     00:00
(9/12): perl-Test-Simple-0.92-127.el6.i686.rpm                               | 110 kB     00:02
(10/12): perl-UNIVERSAL-can-1.15-1.el6.noarch.rpm                            |  12 kB     00:00
(11/12): perl-UNIVERSAL-isa-1.03-1.el6.noarch.rpm                            |  11 kB     00:00
(12/12): perl-devel-5.10.1-127.el6.i686.rpm                                  | 421 kB     00:11
----------------------------------------------------------------------------------------------------
Total                                                                20 kB/s | 3.2 MB     02:40
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : perl-ExtUtils-MakeMaker-6.55-127.el6.i686                                       1/12
  Installing : perl-Test-Harness-3.17-127.el6.i686                                             2/12
  Installing : 1:perl-ExtUtils-ParseXS-2.2003.0-127.el6.i686                                   3/12
  Installing : 4:perl-devel-5.10.1-127.el6.i686                                                4/12
  Installing : perl-Test-Simple-0.92-127.el6.i686                                              5/12
  Installing : perl-UNIVERSAL-isa-1.03-1.el6.noarch                                            6/12
  Installing : perl-UNIVERSAL-can-1.15-1.el6.noarch                                            7/12
  Installing : perl-Test-MockObject-1.09-3.1.el6.noarch                                        8/12
  Installing : perl-Test-Mock-LWP-0.05-1.el6.rf.noarch                                         9/12
  Installing : geoip-1.4.6-1.el6.rf.i686                                                      10/12
  Installing : perl-Geo-IP-1.38-1.el6.rf.i686                                                 11/12
  Installing : awstats-7.0-2.el6.rf.noarch                                                    12/12
  Verifying  : perl-UNIVERSAL-can-1.15-1.el6.noarch                                            1/12
  Verifying  : awstats-7.0-2.el6.rf.noarch                                                     2/12
  Verifying  : perl-Geo-IP-1.38-1.el6.rf.i686                                                  3/12
  Verifying  : 4:perl-devel-5.10.1-127.el6.i686                                                4/12
  Verifying  : perl-UNIVERSAL-isa-1.03-1.el6.noarch                                            5/12
  Verifying  : perl-ExtUtils-MakeMaker-6.55-127.el6.i686                                       6/12
  Verifying  : perl-Test-Simple-0.92-127.el6.i686                                              7/12
  Verifying  : perl-Test-MockObject-1.09-3.1.el6.noarch                                        8/12
  Verifying  : geoip-1.4.6-1.el6.rf.i686                                                       9/12
  Verifying  : perl-Test-Harness-3.17-127.el6.i686                                            10/12
  Verifying  : perl-Test-Mock-LWP-0.05-1.el6.rf.noarch                                        11/12
  Verifying  : 1:perl-ExtUtils-ParseXS-2.2003.0-127.el6.i686                                  12/12

Installed:
  awstats.noarch 0:7.0-2.el6.rf

Dependency Installed:
  geoip.i686 0:1.4.6-1.el6.rf                       perl-ExtUtils-MakeMaker.i686 0:6.55-127.el6
  perl-ExtUtils-ParseXS.i686 1:2.2003.0-127.el6     perl-Geo-IP.i686 0:1.38-1.el6.rf
  perl-Test-Harness.i686 0:3.17-127.el6             perl-Test-Mock-LWP.noarch 0:0.05-1.el6.rf
  perl-Test-MockObject.noarch 0:1.09-3.1.el6        perl-Test-Simple.i686 0:0.92-127.el6
  perl-UNIVERSAL-can.noarch 0:1.15-1.el6            perl-UNIVERSAL-isa.noarch 0:1.03-1.el6
  perl-devel.i686 4:5.10.1-127.el6

Complete!

2. Assumed that the fqdn for the domain is centos63.ehowstuff.local. Copy the file from the awstats.model.conf:

[[email protected] ~]# cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.centos63.ehowstuff.local.conf

3. Change the awstats configuration file for domain centos63.ehowstuff.local :

[[email protected] ~]# vi /etc/awstats/awstats.centos63.ehowstuff.local.conf

Modify at line 122 for log format :

..
..
LogFormat=1
..
..

Modify at line 153, set your hostname :

..
..
SiteDomain="centos63.ehowstuff.local"
..
..

Modify at line 168, set the IP address to exclude from capturing :

..
..
HostAliases="localhost 127.0.0.1 REGEX[centos63\.ehowstuff\.local$] REGEX[^192\.168\.1\.]"
..
..

4. Modify awstat main configuration file, awstats.conf :

[[email protected] ~]# vi /etc/httpd/conf.d/awstats.conf

Add Alias “Alias /report /var/www/awstats/” and “Allow 192.168.1.0/24” to access awstats :

Alias /awstats/icon/ /var/www/awstats/icon/

Alias /report /var/www/awstats/
ScriptAlias /awstats/ /var/www/awstats/
<Directory /var/www/awstats/>
    DirectoryIndex awstats.pl
    Options ExecCGI
    order deny,allow
    deny from all
    allow from 127.0.0.1 192.168.1.0/24
</Directory>

#Alias /css/ /var/www/awstats/css/
#Alias /js/ /var/www/awstats/js/

5. Restart httpd :

[[email protected] ~]# /etc/rc.d/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

6. Manually generate report :

[[email protected] ~]# /var/www/awstats/awstats.pl -config=centos63.ehowstuff.local -update
Create/Update database for config "/etc/awstats/awstats.centos63.ehowstuff.local.conf" by AWStats version 7.0 (build 1.971)
From data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 13
 Found 0 dropped records,
 Found 0 comments,
 Found 0 blank records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 13 new qualified records.

7. Generate HTML from reports :

[[email protected] ~]# /var/www/awstats/awstats.pl -config=centos63.ehowstuff.local -output -staticlink > /var/www/awstats/index.html

8. Change cron setting :

[[email protected] ~]# vi /etc/cron.hourly/00awstats

Make it comment

#exec /usr/bin/awstats_updateall.pl now -configdir="/etc/awstats" -awstatsprog="/var/www/awstats/awstats.pl" > /dev/null

Add the following lines :

..
..
/var/www/awstats/awstats.pl -config=centos63.ehowstuff.local -update > /dev/null
/var/www/awstats/awstats.pl -config=centos63.ehowstuff.local -output -staticlink > /var/www/awstats/index.html
..
..

Examples :

#!/bin/bash

if [ -f /var/log/httpd/access_log ] ; then
#    exec /usr/bin/awstats_updateall.pl now         -confdir="/etc"         -awstatsprog="/var/www/awstats/awstats.pl" >/dev/null
/var/www/awstats/awstats.pl -config=centos63.ehowstuff.local -update > /dev/null
/var/www/awstats/awstats.pl -config=centos63.ehowstuff.local -output -staticlink > /var/www/awstats/index.html
fi
exit 0

9. Monitor the awstats from the following URL :

http://server_IP_Address/report/index.html

The URL will produce something like this :

awstats

Leave a Reply