Requirements

I’m assuming for this quick guide that you already have a website installed and consequently apache.

emerge -av awstats

A quick breakdown on the use flags from gentookit’s equery:

  • apache2 : Add Apache2 support
  • geoip : Add geoip support for country and city lookup based on IPs
  • vhosts : Adds support for installing web-based applications into a virtual-hosting environment

Configuration

Lots of configuration needs to occur for awstats to work correctly:

First, we need to setup a configuration file for the web site so we can update the statistics.
cp /etc/awstats/awstats.model.conf /etc/awstats/awstats..conf

Where fqdn is the fully qualified domain name of your website you’ll be monitoriing. After you’ve copied the default configuration customize it for your particular website.

Second, you need to enable awstats in your apache vhost configuration:

CustomLog /var/www/localhost/log/apache/production.log combined

Alias /awstats/classes “/usr/share/webapps/awstats/6.9-r1/htdocs/classes/”
Alias /awstats/css “/usr/share/webapps/awstats/6.9-r1/htdocs/css/”
Alias /awstats/icons “/usr/share/webapps/awstats/6.9-r1/htdocs/icon/”
ScriptAlias /awstats/ “/usr/share/webapps/awstats/6.9-r1/hostroot/cgi-bin/”
ScriptAlias /awstats “/usr/share/webapps/awstats/6.9-r1/hostroot/cgi-bin/awstats.pl”
ScriptAlias /awstats.pl “/usr/share/webapps/awstats/6.9-r1/hostroot/cgi-bin/awstats.pl”
Options None
AllowOverride None

Order allow,deny
Allow from all

Options ExecCGI
AllowOverride None

Order allow,deny
Allow from all

Options None
AllowOverride None
Order allow,deny
Allow from all
Options None
AllowOverride None
Order allow,deny
Allow from all

And verify the logging output in /etc/apache2/modules.d/00_mod_log_config.conf:
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined
LogFormat “%h %l %u %t \”%r\” %>s %b” common

LogFormat “%{Referer}i -> %U” referer
LogFormat “%{User-Agent}i” agent
LogFormat “%v %h %l %u %t \”%r\” %>s %b %T” script
LogFormat “%v %h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” VLOG=%{VLOG}e” vhost
# You need to enable mod_logio.c to use %I and %O
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %I %O” combinedio
LogFormat “%v %h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %I %O” vhostio

# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a
# container, they will be logged here. Contrariwise, if you *do*
# define per- access logfiles, transactions will be
# logged therein and *not* in this file.
CustomLog /var/log/apache2/access_log common

# If you would like to have agent and referer logfiles,
# uncomment the following directives.
#CustomLog /var/log/apache2/referer_log referer
#CustomLog /var/log/apache2/agent_logs agent

# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#CustomLog /var/log/apache2/access_log combined

And Lastly, you need to add a cron entry to update the statistics on a regular basis:
# AWStats
*/15 * * * * perl /usr/share/webapps/awstats/6.9-r1/hostroot/cgi-bin/awstats.pl -config=www.alunduil.com -update > /dev/null

Everything should be running smoothly but give your installation some time to begin collecting statistics.

© 2011 Alunduil's Hosting Suffusion theme by Sayontan Sinha