kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Setting up awstats

Posted on August 17, 2007

I recently setup awstats on two Intranet servers for a client. Local web server log analysis software seems to be going the way of the Big-eared Hopping Mouse.

  • Analog hasn't been updated in forever.
  • Webalizer hasn't been updated in forever.
  • Firestats is fantastic, I use this on Internet based sites with Google Analytics
    * It's AJAX just doesn't like mod_auth_ntlm or the other way round.

I followed the included PDF file awstats.pdf which covers ninety percent of the process. There's a few caveats in the process. Here's how I did it.

tar zxpfv awstats-XX.tar.gz
mv awstats-XX /usr/local/awstats
mkdir /var/lib/awstats
chmod 777 /var/lib/awstats
cd  /usr/local/awstats
cd tools

Now we can run the config

perl awstats_configure.pl

I did the usual Y,Y,Y,Y and accepted all the defaults. Remember what profile name you set because you will need to add it into cron later.

55 23 * * *     /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=CONFIG-NAME

Lets edit the config file.
If you're on a closed server (not on the Internet) it's nice to have the following set

nano /etc/awstats/awstats.CONFIG-NAME.conf

Change the following two lines. The first, surprisingly allows you to update the statitics from the web browser and the second allows you to view a whole year. Both are disabled by default for safety reasons.

AllowToUpdateStatsFromBrowser=1
AllowFullYearView=3

There is an incosistancy in the awstats documentation with the DirIcons, the default config is

Change DirIcons="/icon"

But you will need to change that to

DirIcons="/awstatsicon"

so it matches the apache configuration further on.

Now, I wanted a complete historical reports from when my logs started. So the first thing I did was to run a report on my whole set of logs

Change the log file setting to look similar to this

LogFile="/usr/local/awstats/tools/logresolvemerge.pl /var/log/apache2/*.log |"

This reads the whole directory and does take some time. Once thats done you can change the LogFile setting to something a little more optimised like

LogFile="/var/log/apache2/access_log-%YY%MM%DD.log"

This assumes your apache is setup like this

CustomLog "|/usr/local/apache2/bin/rotatelogs /var/log/apache2/access_log-%y%m%d.log 86400" combined
ErrorLog "|/usr/local/apache2/bin/rotatelogs /var/log/apache2/error_log-%y%m%d.log 86400"

This means I get a new log file every day.

Once you're happy with the setup, go ahead and run it

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=CONFIG-NAME

Watch out for any errors!

Finally, we can setup apache so we can view the logs. Because I am running this on a closed, single site server this config is going in my global. You may want to put them under a virtual host and/or add some security to them.
Add the following to your httpd.conf

Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicon "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Note there is another inconsitancy in the documentation, it stays

ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi.bin/"

Where really it should say

ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

Now you should now have some nice reports to view over at

http://YOUR-SERVER/awstats/awstats.pl?output=main&config=CONFIG-FILE&framename=index


Related posts

  1. NTLM Authentication on Ubuntu and Apache2 Revisited
    It's been a while since I've had to build an NTLM integrated Apache2 server. So...
  2. NTLM Authentication for apt-get’ed Ubuntu
    Following on from NTLM Authentication on Ubuntu and Apache2 Revisited this morning, this is how...
  3. Setting up and using NFS on Ubuntu
    Network File System, NFS, has been around since Noah first networked his ark. Setting up...
  4. FreeTDS installation directory is not a FreeTDS installation directory
    I recently discovered an error whilst trying to (re)install an older PHP version on a...
  5. SSH Security Ramblings
    SSH - Secure Shell isn't that secure. If you're not using it behind a Layer...

Posted by Kieran


Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.