Quick and simple AWStats setup

How to setup AWStats as a non-admin user on Debian GNU/Linux. The process is not very complicated, but some important points are undocumented, that's why this short how to was written.

This tutorial assumes that AWStats is already installed (if not apt-get install awstats as root). It can be easily adapted to a local AWStats installation.

First create a stats directory in /home/user/public_html and make sure it is readable by www-data.

$ mkdir -m 755 /home/user/public_html/stats/

Create the configuration file awstats.my.domain.conf in this directory:

Include "/etc/awstats/awstats.conf"
LogFile = "/var/log/httpd/access.log"
SiteDomain = "my.domain"
OnlyFiles = "REGEX[^\/~user]"
DirIcons = "icon"
DirData = "/home/user/public_html/stats"

If you want to monitor everything in the domain, remove the OnlyFiles directive. Also you should create a symbolic link to the AWStats icon directory: ln -s /usr/share/awstats/icon/ (or copy it if it does not work.)

First AWStats must analyze the log file. This will create a bunch of data files to keep track of the site statistics:

      perl /usr/lib/cgi-bin/awstats.pl \
      -configdir=${stats_dir} \
      -config=henry.precheur.org \
      -dir=${stats_dir} \

The tricky part was the environment variable AWSTATS_ENABLE_CONFIG_DIR. If you do not set it, AWStats will look for the configuration file in /etc/awstats.

Run the following command to generate report files:

      perl /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl \
      -configdir=/home/user/public_html/stats \
      -config=my.domain \
      -dir=/home/user/public_html/stats \

To look at the statistics of your website, just open the file awstats.my.domain.html. Or use the url http://my.domain/~user/stats/awstats.my.domain.html.