How to Setup AWStats (Apache Log Analyzer) on CentOS, RHEL and Fedora

Channel: Linux
Abstract: Now execute following command to update logs files # perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=tecadmin.net -updateStep 4 – Configure

AWStats is a free and very powerful tool that creating statics by analyzing Apache log files, ftp or mail servers. AWStats log analyzer works on CGI or command line interface and generate graphical statics from log files.

This how to guide will help you to install and configure AWStats Apache Log Analyzer on CentOS, RHEL and Fedora systems. This article has been tested with CentOS 7.2 only.

Step 1 – Setup EPEL Repository

Firstly install EPEL repository on your system using below command.

# yum install epel-release
Step 2 – Install Apache Server

AWStats required Apache web server to be running. If you don’t have Apache install Use below commands else you already have httpd installed skip this step.

# yum install httpd
# chkconfig httpd on
# service httpd start
Step 3: Install AWStats

After installing web server, Let’s install AWStats package using yum. Its will also install all other required dependencies.

# yum install awstats
Step 4 – Configure Apache for AWStats

By default AWStats creates an Apache configuration file /etc/httpd/conf.d/awstats.conf. Default configuration is ok to use except allow from access. If you need to access awstats from network, update the allow from ip with your system or network ip from where we need to access it.

# vim /etc/httpd/conf.d/awstats.conf
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"

<Directory "/usr/share/awstats/wwwroot">
    Options None
    AllowOverride None
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require host 192.168.0.0/24
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order allow,deny
        Allow from 192.168.0.0/24
        Allow from ::1
    </IfModule>
</Directory>

<IfModule mod_env.c>
    SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>

Restart Apache service to reload new settings

# service httpd restart
Step 5 – Create AWStats Configuration File

Its required to create an configuration file for each of your website for which statics need to generate. Copy AWStats example configuration file with new name and make changes as below.

# cp /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.tecadmin.net.conf
# vim /etc/awstats/awstats.tecadmin.net.conf

Update below settings in awstats.tecadmin.net.conf file

LogFile="/var/log/httpd/tecadmin.net-access_log"
SiteDomain="tecadmin.net"
HostAliases="tecadmin.net www.tecadmin.net"

Now execute following command to update logs files

# perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=tecadmin.net -update
Step 6 – Schedule Cron to Update Logs

Schedule a cron job to regularly update AWStats database using newly created log entries. Add new cron job in crontab like below. Read examples of cron scheduling

 0 2 * * * /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=tecadmin.net -update
Step 7 – Access AWStats in Browser

Use your server ip address or domain name to access AWStats statics. Change domain name at the end of url as per your settings.

https://tecadmin.net/awstats/awstats.pl?config=tecadmin.net

Congratulation’s! you have successfully configured AWStats for you website. Read our next article to Setup vnStat ( Web based Network Monitoring Tool ) and Install Munin Network Monitoring Tool on your Linux system.

Ref From: tecadmin

Related articles