Awstats & virtual hosts

Gentoo has finaly moved away from webapp-config and simplified updating awstats. The example of apache config file setting awstats for apache virtual hosts runnig wsgi application is given bellow. Prerequisites are apache proxy for wsgi app, and awstats visible at www.some_domain.com/awstats.pl using authentication.

    <VirtualHost *:80>
        ServerName www.some_domain.com
        Serveralias some_domain.com
        ServerAdmin admin@some_domain.com

        ErrorLog /var/log/apache2/www.some_domain.com-error.log
        CustomLog /var/log/apache2/www.some_domain.com-access.log combined

        # awstats config
        Alias /awstats/classes "/usr/share/awstats/wwwroot/classes/"
        Alias /awstats/css "/usr/share/awstats/wwwroot/css/"
        Alias /awstats/icon "/usr/share/awstats/wwwroot/icon/"
        ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"
        ScriptAlias /awstats "usr/share/awstats/wwwroot/cgi-bin/awstats.pl”
        ScriptAlias /awstats.pl "usr/share/awstats/wwwroot/cgi-bin/awstats.pl”

        <Directory "/usr/share/awstats/wwwroot">
                AllowOverride None
                Options None
                Order allow,deny
                Allow from all

                AuthType Basic
                AuthName "AWStats authenticated zone"
                AuthUserFile /etc/awstats/.htpasswd
                Require valid-user
        </Directory>
        <Directory "/usr/share/awstats/wwwroot/cgi-bin">
                SetHandler cgi-script
                Options +ExecCGI
        </Directory>

        ProxyPass /awstats !
        ProxyPass /awstats.pl !

        ProxyPass / http://localhost:5005/ retry=5
        ProxyPassReverse / http://localhost:5001/
        ProxyPreserveHost On
        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>
    </VirtualHost>

Awstats config file (in /etc/awstats/) with geo-ip (emerge dev-perl/Geo-IP)

LogFile="/var/log/apache2/www.some_domain.com-access.log"

LogType=W
LogFormat=1
LogSeparator=" "
HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]"
DNSLookup=2
DirCgi="/cgi-bin"
DirIcons="/awstats/icon"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=2

LevelForFileTypesDetection=1
LevelForWormsDetection=2

SiteDomain="www.some_domain.com"
DirData="/home/some_user/awstats"

LoadPlugin="geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat"

To test configuration run
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=www.some_domain.com -update

If you wish cron to handle update on every hour:
crontab -e -usome_user

0 * * * * cd /etc/awstats/ && /usr/share/awstats/wwwroot/cgi-bin/awstats.pl  -config=www.some_domain.com -update  >/dev/null 2>&1

Error with log file

Error: LogFile parameter is not defined in config/domain file
Setup ('www.dajstadas.com' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

obviously check LogFile and read permissions, however, this might fail if you call awstats update outside /etc/awstats directory. Retry with


cd /etc/awstats/ && /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=www.some_domain.com -update