httpLog

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

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 on CentOS 6.5 only.

Step 1: Setup EPEL Repository

Install EPEL repository using below commands on RHEL/CentOS Systems.

CentOS/RHEL 6: # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm  CentOS/RHEL 5: # rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Step 2: Install Apache Web 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 Package

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 /awstats/icon/ /var/www/awstats/icon/ 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     allow from 192.168.1.0/24 </Directory>  #Alias /css/ /var/www/awstats/css/ #Alias /js/ /var/www/awstats/js/

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"

Step 6: Set Up 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 /var/www/awstats/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.

http://svr1.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.