awstats_on_lenny

AWStats on Debian Lenny with virtual hosts

Quick setup for AWStats:

install the debian package for AWStats. Make a copy of the base config file:

cd /etc/awstats/
cp awstats.conf awstats.www.mysite.org.conf

edit it to your needs, especially, you need to set:

LogFile="/var/log/apache2/host.mysite.org-access.log"
SiteDomain="mysite.org"
SkipDNSLookupFor="REGEX[^192\.168\.]"
SkipHosts="REGEX[^192\.168\.]"

that does: * set the log file to use * set the name that is used for the site you are studying, to avoid referee stats on your own site * both last lines I added to avoid having all my accesses from the intranet on the website in the statistics.

If you use logrotate and want to start having statistics on all the last logs, you have to concatenate them all in the above named log file, ordered by time. You can use a quick script like this (if you have logs numbered and gz compressed, I had 52 files):

\#!/bin/bash
for i in `seq 52 -1 2`;
do
    zcat host.mysite.org-access.log.$i.gz >> mysite-access.log
done

Then, you just have to concatenate the two most recent files in log.

Then, run the statistics:

/usr/lib/cgi-bin/awstats.pl --config=www.mysite.org

if it failed, you should clean /var/lib/awstats/ and start again.

Add a redirection to the cgi-bin directory that contains awstat

ScriptAlias /cgi-bin/ /usr/local/lib/cgi-bin/
<Directory "/usr/local/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

Your statistics are then usually accessible on your server, at this path:

http://www.mysite.org/cgi-bin/awstats.pl?config=www.mysite.org

Finally, add a crontab job, with crontab -e:

*/35   * * * * /usr/lib/cgi-bin/awstats.pl -config=www.mysite.org > /dev/null

  • Created: 28/11/13 06:44
  • Modified: 28/11/13 06:44