Adding AWstats to Gentoo

Written by Peter Davies on .

I followed the following basic steps:

USE="vhosts" emerge -p awstats

Remove -p pretend after you've seen what dependancies are required.

Create conf file:

ln -s /usr/share/webapps/awstats/6.9-r1/postinst-en.txt /etc/apache2/vhosts.d/awstats.conf

Edit the apache conf file:

nano /home/dev/apache/conf/vhosts.conf

Add something similar like this, changing the default location of awstats for security. Further access restrictions are set below:

ScriptAlias /pkd-stats "/usr/share/webapps/awstats/6.9-r1/hostroot/cgi-bin/"
Alias /pkd-stats-icons "/usr/share/webapps/awstats/6.9-r1/htdocs/icon/"

        Options +ExecCGI +FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all

        Options +ExecCGI +FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all

CustomLog "|/usr/sbin/cronolog /home/dev/apache/logs/tcs-%Y-%m-%d.log" combined

Duplicate the config file creating a new for the domain that your running and edit:

cd /etc/awstats/
cp awstats.module.conf
nano /etc/awstats/

Set the following:

LogFile="/usr/bin/ /home/dev/apache/logs/pkd-*.log |"
SkipHosts=" REGEX[^192\.168\.] REGEX[^10\.]"

Change the owner of the files:

cd /usr/share/webapps/awstats/6.9-r1/hostroot
chown -R apache:apache datadir
chown -R apache:apache cgi-bin

Now update the stats from existing log files

perl -update

Now password protect the access.
Create the password file (replace the word username & password with anything you like)

htpasswd -bc /etc/awstats/.htpasswd username password

In my case it involved editing the main httpd.conf file and adding the awstats.conf file uncommenting:

    AuthType Basic
    AuthName "AWStats authenticated zone"
    AuthUserFile /etc/awstats/.htpasswd
    Require valid-user

Reload Apache

apache2ctl configtest
apache2ctl graceful