Skip to content. | Skip to navigation

Navigation

Personal tools

Web Applications

This guide shows how to build several web applications and servers. The basic concept is that of an Apache 2 webserver fronting several application servers (such as Apache Tomcat and Plone). We'll be hosting several domains and handling SSL. To avoid unnecessary rebuilding we'll attempt to reuse existing infrastructure.

awstats

A Web/FTP/Mail server log file analyser

awstats is a log file analyser. You may not care for it.

awstats unpacks in-situ. You need only point your webserver at it. Oh yes, and change a few settings...

Configuration

First of all, make sure that awstats and yourself agree on the version of Perl you are using. Make sure the #! line at the start of .../awstats-6.4/wwwroot/cgi-bin/awstats.pl is the same as your normal Perl (try type perl).

System Directories

Create a cache directory for historical data:

mkdir /www/awstats/cache
chown webservd:webservd /www/awstats/cache

Note

The choice of who to have the directory owned by will be determined by who you run the crontab as. It might as well be yourself as awstats will only be reading it.

Create an awstats config file directory:

su
mkdir /etc/awstats

Apache 2

You need to edit your Apache configuration for awstats. There is a auto-frobbing scripts but it makes far too many assumptions about how you lay your configuration files out. Suffice it to say that:

  1. You need to set up a CustomLog format.

    This isn't as horrendous as it sounds, more a case of finding where CustomLog is currently set and changing common at the end to combined. In fact, you could just make a statement about your LogFormat and be done.

  2. You need to point at the awstats files. In the 6.4 distribution the suggestions are wrong, the code looks for /icon/* and not /awstatsicons/*:

    Alias /awstatsclasses "/usr/local/awstats-6.4/wwwroot/classes/"
    Alias /awstatscss     "/usr/local/awstats-6.4/wwwroot/css/"
    Alias /icon           "/usr/local/awstats-6.4/wwwroot/icon/"
    ScriptAlias /awstats/ "/usr/local/awstats-6.4/wwwroot/cgi-bin/"
    

Warning

awstats is a very popular point of attack (lloking at some sample log files). Put some access control on this host/location!

Per-Logfile/VirtualHost

For each logfile you need to copy .../awstats-6.4/wwwroot/cgi-bin/awstats.model.conf to /etc/awstats/awstats.*domainname*.conf and then edit it:

  1. change LogFile according to where you put your webserver (or FTP or Mail server's) logfiles, eg:

    LogFile="/www/apache2/logs/www.example.com/%YYYY-1-%MM-1/access_log"
    

    where the %YYYY-1 and %MM-1 perform a little trick. Suppose you update the awstats cache once an hour, if you have passed over midnight (on the last day of the month) then you can get in a mess with where the logfile is (assuming you rotate them). The %FOO-1 says to take the value of FOO (in a strftime()-ish format) and calculate it as of an hour ago. Very neat.

  2. change SiteDomain to be the canonical name of your site, eg. www.example.com.

  3. change HostAliases to the nicknames for your site, eg. ServerAlias values from Apache

  4. uncomment LoadPlugin="geoip GEOIP_STANDARD"

crontab

Having sorted out the display of the logs, we need to keep the display updated. The obvious way is via a crontab entry which is as easy as pie. A simple scripts that for each of the configurations run the awstats update command:

#! /bin/ksh

cd /etc/awstats

for s in awstats.*.conf ; do
    c=${s#awstats.}
    c=${c%.conf}
    /usr/local/awstats-6.4/wwwroot/cgi-bin/awstats.pl -config=$c -update >/dev/null 2>&1
done

and add a crontab entry (for whomever has permission to write to /www/awstats/cache as above) to run at, say, five past the hour.

Back Dating

You can pass the -logfile argument to awstats.pl to convince to update the cache for a period in history.

You can get problems with awstats not recognising some entries which are marked incorrectly as old records. YMMV.

Document Actions