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.
- The website url is http://my.domain/~user/
- The log file is /var/log/httpd/access.log.
- The public html directory is /home/user/public_html.
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:
$ env AWSTATS_ENABLE_CONFIG_DIR=1 \ perl /usr/lib/cgi-bin/awstats.pl \ -configdir=${stats_dir} \ -config=henry.precheur.org \ -dir=${stats_dir} \ -update
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:
$ env AWSTATS_ENABLE_CONFIG_DIR=1 \ perl /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl \ -configdir=/home/user/public_html/stats \ -config=my.domain \ -dir=/home/user/public_html/stats \ -awstatsprog=/usr/lib/cgi-bin/awstats.pl
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.