awstats - Simple Network Management

Awstats - Simple Network Management Protocol

[Ref: Awstats]

Quick notes for installing AWSTATS within my environment:

  • UnChroot’d Apache
  • mod_perl
  • log files: nginx, apache 1.x, squid

Download the awstats files and extract to a known directory

# export SRC=/path/to/awstats-7.1.1
# cd $SRC

Set the appropriate permissions that we will require for using the files (such as other readable for the perl scripts, and ‘x’ for the directories:

# find . -type d -print -exec chmod +x "{}" ";"
# find . -type f -print -exec chmod +r "{}" ";"

Move the files into the appropriate locations for how we manage our websites.

# mv tools /usr/local/awstats
# mv wwwroot /var/www/awstats
# mkdir -p /etc/awstats
# mv /var/www/awstats/cgi-bin/awstats.model.conf /etc/awstats/
# mkdir -p /var/db/awstats

Set at least one perl script as executable

# chmod + /usr/local/awstats/

Run the configuration to create some configuration files

# /usr/local/awstats/
# perl /usr/local/awstats/

Responses to prompt for httpd.conf:

  • /var/www/conf/httpd.conf

Note that installation will make some modifications that will need review.

Awstat Configuration Updates

We’re using a path different from the standard install, and need to update the appropriate perl scripts:

File extract: /usr/local/awstats/ and /usr/local/awstats/

my $Awstats='/var/www/awstats/cgi-bin/';

Likewise, the default configuration template awstat.model.conf and all our configuration files need to be updated to reflect the below:

File extract: /etc/awstat/awstat.model.conf


Example customisation for our squid cache include:

File extract: /etc/awstat/awstat.squid-cache.conf


Apache Configuration Update

File: /var/www/conf/modules/awstats.conf

# Directives to allow use of AWStats as a CGI
Alias /awstatsclasses "/var/www/awstats/classes/"
Alias /awstatscss "/var/www/awstats/css/"
Alias /awstatsicons "/var/www/awstats/icon/"
ScriptAlias /awstats/ "/var/www/awstats/cgi-bin/"
# This is to permit URL access to scripts/files in AWStats directory.
<Directory "/var/www/awstats">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all

Root Cron Job

/usr/local/awstats/ now


Apache needs to run in chroot for a number of reasons, including:

  • awstats config, db is outside chroot
  • perl modules used by awstats are outside chroot

Squid Access Log Format

File extract: /etc/squid/squid.conf

logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
access_log /var/squid/logs/access.log combined