Installing AWStats (Part 1)
Author: Stuart Millington Publishing date: 21.06.2003 22:44
This guide is intended to show you how to install AWStats on a VS.
Obviously, there is no warranty with this guide and the only support telephone number is 0898... (only joking). On a serious note, you should always make certain that you have a complete and working backup of any server before you do anything to it. If you mess up your server by attempting to install this program don't blame me as all I'm doing here is documenting how I got AWStats working on my server ;-)
This guide is not aimed at anyone who is new to administering a server from the shell, so I've assumed that you will know the basics of administering your VS from a shell rather than the control panel.
The reason I'm looking at AWStats is to get a better idea of web site visitor's country of origin than Webalizer provides - I mean Webalizer's author still thinks that ".com" is an American domain! So I will be configuring AWStats to use geographical IP lookups in the next article. Of course that approach also has problems, but will provide a different view. This article covers the basic installation, which relies on domain names to determine the visitor's country of origin.
I am not removing Webalizer in this installation as I intend to run both analysers side by side to compare the results.
The installation instructions here are based upon following the standard AWStats install instructions at http://awstats.sourceforge.net/docs/awstats_setup.html, but they are modified based upon the changes/settings required to install AWStats on a DSVR VS.
Please remember that the following configuration is to my personal tastes, so you may want to fine-tune the configuration once it is up and running.
For your installation you will need to replace "/www/vhtdocs/sitedir/" with the path to your site's document root directory and "yoursite" to the name you give to your site in the "awstats.yoursite.conf" filename.
Installation:
- Download AWStats from: http://awstats.sourceforge.net/
- Unpack the downloaded archive on your hard drive and go to the "wwwroot/cgi-bin" directory.
- Copy (or rename) "awstats.model.conf" to "awstats.yoursite.conf" and open it in a text editor. (You may need to remove the read-only attribute if the downloaded file has this set!)
- Copy the "awstats_buildstaticpages.pl" file from the tools directory into the cgi-bin directory.
In the configuration file "awstats.yoursite.conf":
- Change the "LogFile" value to the location of your site's log file, e.g. "/www/logs/yoursite-access_log". You must, obviously, have set-up Apache to write a custom log file for your site (along with logrotate) before you can analyse the logs! If you have not already done so, then you should read http://www.dsvr.co.uk/support_documentation/Extensions/webalizer.html and http://www.dsvr.co.uk/support_documentation/Extensions/logrotate.html, which show you how to configure Apache and logrotate.
- Change the "SiteDomain" to your domain name (without the leading "www."), e.g. "yourdomain.co.uk"
- Set the "HostAliases" value accordingly, e.g. "www. yourdomain.co.uk w3. yourdomain.co.uk localhost 127.0.0.1".
- Change the "DNSLookup" value to "1" - as your VS's httpd.conf will have reverse DNS lookup turned off by default.
- "DirData" is where AWStats stores its data. I don't like data in the cgi-bin directory, so I'll create "/www/vhtdocs/sitedir/awstats" and set "DirData" to this. (If you are running AWStats from a cron job, the "admin" user must be able to write to this directory.)
- Change "DirCgi" to an absolute directory, e.g. "/www/vhtdocs/sitedir/cgi-bin"
- I like to keep common files in one place. So, under the awstats directory, create the "icon" directory (remember to copy them there later) and change "DirIcons" to "/awstats/icon"
- Leave "AllowToUpdateStatsFromBrowser" set to "0" so that only the cron job can update the statistics.
- Change "SaveDatabaseFilesWithPermissionsForEveryone" to "0"
- Screen size detection is never accurate, so ignore the "LogScreenSizeUrl" value.
- Set the primary language value "Lang", e.g. mine is set to "en"
- Change "DetailedReportsOnNewWindows" to "0"
Upload AWStats:
- FTP (or SFTP) to your web server as "admin"
- MKDIR the "awstats" directory in your site directory and upload the "icon" directory (from "wwwroot/icon" as a sub-directory.
- Change to your cgi-bin directory (making sure that *.pl and *.pm files are uploaded in ASCII mode) and upload the files from "wwwroot/cgi-bin" - don't upload "awstats.model.conf" as there is no point, it is just a default configuration.
- "awstats.pl" and "awstats_buildstaticpages.pl" are CGI scripts, so make sure that you run "chmod 755 awstats.pl" (and again for "awstats_buildstaticpages.pl").
Test:
- Log in to your server as "admin" - ideally via SSH, but Telnet will work...
- Change directory to sitedir/cgi-bin
- Test the configuration with "./awstats.pl -config=sitedir -update" - this may take a few minutes.
Create shell script to run the basic and full results pages:
- Create a script file in the cgi-bin directory called "awstats.sh" and open it for editing, e.g. with pico and enter the following 4 lines:
- #!/bin/bash
- cd /www/vhtdocs/sitedir/cgi-bin
- perl awstats.pl -config=yoursite -update -output -staticlinks > /www/vhtdocs/sitedir/awstats/index.html
- perl awstats_buildstaticpages.pl -awstatsprog=/www/vhtdocs/sitedir/cgi-bin/awstats.pl -config=yoursite .output -dir=/www/vhtdocs/sitedir/awstats/
- Save the file.
- Chmod the file so that it is executable, e.g. "chmod u+x"
To run the analysis at 10 minutes past every hour:
- Edit (as "admin") your crontab with "crontab -e"
- Add the following line to the crontab: "10 * * * * /www/vhtdocs/sitedir/cgi-bin/awstats.sh"
- Save the crontab.
Now, view the results at www.yourdomain.co.uk/awstats/
That's the basic statistics up and running. Let me know if you have any problems installing AWStats on a VS with this guide, as I may have done something out of habit and forgotten to write it down here :-(
Next time I'll look at identifying visitors' countries of origin by their IP address.
The copyright of some of the images that are used on this site is held by 3rd parties. The images are used for review purposes under the Fair Use / Fair Dealing provisions of copyright law. If any copyright holder objects to such use, please use the contact address below.

