How to Install Awstats on CentOS 5.5

Share this Article :

In this tutorial i will guide you on how to install AWStats in CentOS server. AWStats is a free powerful tool that generates advanced websites statistics, graphically. This tutorial assumes that you have root access for CentOS with Apache server has been installed with domain www.my.local properly configured.

Steps :

1. Download and install the rpmforge repository.

For x86 (32-bit) systems

    [[email protected] ~]# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
    

For x64 (64-bit) systems

    [[email protected] ~]# rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
    

2. Install AWStats with yum command:

    [[email protected] ~]# yum --enablerepo=rpmforge install awstats -y
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * addons: centos.maulvi.net
     * base: centos.maulvi.net
     * epel: ftp.cuhk.edu.hk
     * extras: centos.maulvi.net
     * rpmforge: fr2.rpmfind.net
     * updates: mirror.yourconnect.com
    addons                                                        |  951 B     00:00
    base                                                          | 1.1 kB     00:00
    epel                                                          | 3.7 kB     00:00
    extras                                                        | 2.1 kB     00:00
    rpmforge                                                      | 1.1 kB     00:00
    updates                                                       | 1.9 kB     00:00
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package awstats.noarch 0:7.0-2.el5.rf set to be updated
    --> Processing Dependency: perl(Geo::IP) for package: awstats
    --> Running transaction check
    ---> Package perl-Geo-IP.i386 0:1.38-1.el5.rf set to be updated
    --> Processing Dependency: libGeoIP.so.1 for package: perl-Geo-IP
    --> Running transaction check
    ---> Package geoip.i386 0:1.4.6-1.el5.rf set to be updated
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =====================================================================================
     Package             Arch           Version                   Repository        Size
    =====================================================================================
    Installing:
     awstats             noarch         7.0-2.el5.rf              rpmforge         1.2 M
    Installing for dependencies:
     geoip               i386           1.4.6-1.el5.rf            rpmforge         782 k
     perl-Geo-IP         i386           1.38-1.el5.rf             rpmforge         118 k
    
    Transaction Summary
    =====================================================================================
    Install       3 Package(s)
    Upgrade       0 Package(s)
    
    Total download size: 2.1 M
    Downloading Packages:
    (1/3): perl-Geo-IP-1.38-1.el5.rf.i386.rpm                     | 118 kB     00:01
    (2/3): geoip-1.4.6-1.el5.rf.i386.rpm                          | 782 kB     00:13
    (3/3): awstats-7.0-2.el5.rf.noarch.rpm                        | 1.2 MB     00:23
    -------------------------------------------------------------------------------------
    Total                                                 52 kB/s | 2.1 MB     00:41
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing     : geoip                                                         1/3
      Installing     : perl-Geo-IP                                                   2/3
      Installing     : awstats                                                       3/3
    
    Installed:
      awstats.noarch 0:7.0-2.el5.rf
    
    Dependency Installed:
      geoip.i386 0:1.4.6-1.el5.rf            perl-Geo-IP.i386 0:1.38-1.el5.rf
    
    Complete!
    

3. Modify AWStats Apache Configuration

    [[email protected] ~]# vi /etc/httpd/conf.d/awstats.conf
    
    Alias /awstats/icon/ /var/www/awstats/icon/
    
    ScriptAlias /awstats/ /var/www/awstats/
    <Directory /var/www/awstats/>
        DirectoryIndex awstats.pl
        Options ExecCGI
        order deny,allow
        allow from all
    </Directory>
    

4. Rename config file localhost.localdomain.conf to www.my.local.conf

    [[email protected] ~]# mv /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.www.my.local.conf
    

5. Modify “SiteDomain” on Line 153 as below

    SiteDomain="www.my.local"
    

6. Modify “HostAliases” on Line 168 as below

    HostAliases="localhost 127.0.0.1 REGEX[my\.local$] REGEX[^10\.0\.0\.]"
    

7. Update Statistics

    [[email protected] ~]# /usr/bin/awstats_updateall.pl now -confdir="/etc" -awstatsprog="/var/www/awstats/awstats.pl"
    
    [[email protected] ~]# /usr/bin/awstats_updateall.pl now -confdir="/etc" -awstatsprog="/var/www/awstats/awstats.pl"
    Running '"/var/www/awstats/awstats.pl" -update -config=www.my.local -configdir="/etc/awstats"' to update config www.my.local
    Create/Update database for config "/etc/awstats/awstats.www.my.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...
    Jumped lines in file: 0
    Parsed lines in file: 0
     Found 0 dropped records,
     Found 0 comments,
     Found 0 blank records,
     Found 0 corrupted records,
     Found 0 old records,
     Found 0 new qualified records.
    

8. Restart the apache service

    [[email protected] ~]# /etc/init.d/httpd start
    

8. Verify Install

    http://CentOS_server/awstats/awstats.pl?config=www.my.local
    


Leave a Reply