Awstats and IIS Debian Set Up

This following should take the reader through a complete awstats setup from start to finish.  The reader should be cognizant of the possible impacts of some of the commands casually mentioned below.  This was done on Debian’s Lenny distro with apache2.  The reader should be very familiar with setting up an Apache2 instance.

  1. Apt-get awstats.
  2. Configure Apache2:  Use   /usr/share/doc/awstats/examples/apache.conf  as your template for whatever you end up with in /etc/apache2/sites-available/awstats.  Apache configs are subject to personal preferences too much to be more specific than this.
  3. Link /etc/apache2/sites-available/awstats to /etc/apache2/sites/enabled/awstats. ‘ln -s /etc/apache2/sites-available/awstats /etc/apache2/sites-enabled/awstats’
  4. Restart apache2 ‘/etc/init.d/apache2 restart’

IIS Log Set Up Minutae

Before you can make awstats useful, your logs from your IIS instance have to meet some minimum requirements.  I don’t remember the IIS logging defaults, but given Microsoft’s hostility to Free software, it’s likely a plain-vanilla IIS log will not work with awstats.

What’s especially miserable about IIS is setting the ‘host header value’ on Win2003.  Somehow this value ended up being null for me and any attempts to change it end up with a 404 error.  I have a hard time maintaining the value of Microsoft products with nasty bugs like this….

The following fields should be used in the log: Client IP Address, Service Name, URI Stem, URI Query, Protocol Status, Bytes Sent, User Agent, Referer.  Of those, Bytes Sent is required for awstats to work!!! There are other fields that might be useful in special situations like %logname, but that’s for you to poke through the default awstats.conf file and figure out based on your needs.

Now that your web server is ready, set up awstats for IIS logs.  My logs come from a Windows 2003 machine.

Awstats.conf  Set Up

  1. Check a log.  You need to extract the hostname (s-sitename) from the log.  You will need this name and it will be referred to as $s-sitename from now on.
  2. Copy an awstats.conf file to awstats.$s-sitename.conf where $s-sitename.
  3. Open the newly copied awstats.$s-sitename.conf file.
  4. Set the path of where the log files reside.
  5. Make your log string.  It will probably be a custom incantation.
  6. Set LogFile.  If your IIS logs are rotated, then you *might* be able to use logresolvemerge.pl to feed awstats logs.  logresolvemerge.pl does the work of feeding logs to awstats in the required time-sensitive manner.  Otherwise, you may need to work out feeding awstats logs oldest data first.
  7. Change the SiteDomain value to whatever $s-sitename is.
  8. Add HostAliases as needed.
  9. Save the file and exit.
  10. Change directory to your web root for your awstats page.
  11. Run “/usr/lib/cgi-bin/awstats.pl -config=$s-sitename  -showcorrupted” Where $s-sitename is whatever your hostname may be in the log file.  This incantation will tell you if there are problems with the logs while processing .  IIS log incantations are fiddley, so there will probably be several tries before your log string (step 5) is okay and awstats works as expected.
  12. Run “/usr/lib/cgi-bin/awstats.pl  -config=$s-sitename  -output > $your/path/to/web/root/index.html”  Where $your/path/to/web/root is the same as your apache config web root.  You’ll have basic information now. You should not need the -static option so frequently mentioned elsewhere if your Apache2 config is set up like the example given.  Optionally, you can set LogFile=”/some/custom/path” to feed awstats in a customized manner.

For the rest of the reports, I use the awstats_updateall.pl script located in /usr/share/doc/awstats/examples.  I recall it needs a copy of awstats.pl in the same directory for it to work.

Essential documentation for awstats is at their Sourceforge site.

Leave questions as comments.

Trackbacks Comments