This page looks best with JavaScript enabled

Setup AWStats Site

 ·  ☕ 3 min read

About

AWStats is log file analyzer most commonly used to show website traffic information (how many hits your site received at a given time or period).

Setup

You can install AWStats from your distro’s repo (most distros have it) or from AWStats. The Debian distros I use tend to be a little behind the latest released version from AWStats so choose your option accordingly.

A note in selecting your source:

I ran into an issue where all of my mobile traffic was being reported as “unknown” in AWStats. Upon looking into this, I found an issue with the version of perl and awstats. My options were to downgrade perl (not exactly a desirable solution) or get a newer version of AWStats (from outside of Debian’s repo as I was on the latest in the repo).

From Distro’s Repo

This option for install is dependent upon your distro of course but is the easiest and quickest method.

For Debian:

From ‘source’

note: this guide loosely follows this rackspace guide

  1. download awstats
  2. extract it and move it to a desired location (e.g. /opt as I have a version 7.0.2x installed from the repos in /usr/local/awstats)
  3. copy the awstats.model.conf (from [awstats]/wwwroot/cgi-bin/) to the /etc/awstats dir and name it accordingly (e.g. awstats.dradux.com.conf) and edit as follows:
    LogFile="/var/log/apache2/access.log"
    #2014-02-06:DRAD:
    # The following lines will load all (historic) log files; needed for a complete rebuild of the index. NOTICE: check all files from /var/log/apache2/access* and load all
    #LogFile="perl /usr/share/awstats/tools/logresolvemerge.pl /var/log/apache2/access.log.*.gz |"
    #LogFile="/var/log/apache2/access.log.1"
    ...
    SiteDomain="dradux.com"
    ...
    HostAliases="localhost 127.0.0.1"
    ....
    DNSLookup=1
    ...
    DirData="/var/lib/awstats"
    ...
    DirIcons="/awstats/icon
    ...
    AllowFullYearView=3
  1. modify apache2 confs to point to manual awstats instance info//:
    # drad:2014-07-18: old (distro) awstats instance.
    #Alias /awstats/icon "/usr/share/awstats/icon/"
    #Alias /awstatsicon "/usr/share/awstats/icon/"
    #ScriptAlias /awstats "/usr/lib/cgi-bin/"
    #new (manual) awstats instance info.
    Alias /awstats/icon "/opt/awstats-7.3/wwwroot/icon/"
    Alias /awstatsicon "/opt/awstats-7.3/wwwroot/icon/"
    ScriptAlias /awstats "/opt/awstats-7.3/wwwroot/cgi-bin/"
  1. move the /var/lib/awstats directory to retain the old stats and create a new /var/lib/awstats directory
  2. restart apache service
  3. modify the /etc/awstats/awstats.dradux.com.conf file LogFile setting to load/reload ALL data
  4. kick off a manual update:
    perl /opt/awstats-7.3/wwwroot/cgi-bin/awstats.pl  -config=dradux.com -update
  1. hit the web app to verify stats: https://dradux.com/awstats/awstats.pl?config=dradux.com
  2. if everything is copacetic, modify the /etc/awstats/awstats.dradux.com.conf file to use your proper/current LogFile only (no need to load all logs every time as AWStats keeps track of what it has processed)
  3. add a crontab entry to keep AWStats up-to-date (runs every 10 minutes)//:
    */10  *  *  *  *  perl /opt/awstats-7.3/wwwroot/cgi-bin/awstats.pl  -config=dradux.com -update >/dev/null

AWStats should now be installed, configured, and ready for use. If you install from source, I’d recommend adding AWStats RSS Feed to your feed reader to make sure you stay aware of updates.

Share on

drad
WRITTEN BY
drad
Sr. Consultant