User Tools

Site Tools


Installing awstats

Install awstats:

apt-get install awstats

Enable mod_cgi:

a2enmod cgi
service apache2 restart

Fixing cron job permissions

On debian the Apache logs belong to the group adm. This is done by logrotate. By default the cron job for awstats runs as www-data and thus can not access the logs.

To fix this add a new system user that belongs to the adm group.

adduser --system --ingroup adm --no-create-home --disabled-password awstats-cron

We don't want to add www-data to this group because that gives www-data way more permissions than it should have.

Change the cron script so that the user awstats-cron is used instead of www-data.

sed -i -e's/www-data/awstats-cron/' /etc/cron.d/awstats

Set the ownership for any existing files:

chown awstats-cron:www-data /var/lib/awstats/*
chown -R awstats-cron /var/cache/awstats
chown awstats-cron /var/lib/awstats

Migrating awstats to a new server

Set an environment variable for the destination server:

export TARGET_SERVER=<destination host>

Copy the awstats configuration and data files:

scp -r /etc/awstats/* $TARGET_HOST:/etc/awstats
scp -r /var/lib/awstats/* $TARGET_HOST:/var/lib/awstats

If you enforce access restrictions with htaccess don't forget to copy the user database. Example:

scp -r /etc/apache2/htpasswd $TARGET_HOST:/etc/apache2/


Umlauts displayed incorrectly

Install the Perl module URI::Escape.

Uncomment the option LoadPlugin=“decodeutfkeys” in your config files.

apt-get install liburi-perl
find /etc/awstats/ -type f | xargs -n1 sed -i -e's/^# *\(LoadPlugin="decodeutfkeys"\)/\1/'

Timezone wrong

When the time of the last update is off by a multiple of hours it is most likely that the timezone is configured wrongly.

Fix the timezone:

dpkg-reconfigure tzdata
awstats.txt · Last modified: 2015/09/27 22:18 by sebastian