in

ASP.NET Weblogs

Brian Desmond's Blog

Inherits Network.Admin
Implements IOneManBand

Installing AWStats & Perl under IIS 6

I’ve always been a big fan of AWStats for doing my daily log file analysis. It produces nice clean reports, and it’s fairly easy to configure too. The downside on Windows is that one has to install Activestate Perl. This only takes a couple of minutes, though. So, I’m going to cover how to install Perl on IIS 6, and then, how to setup your AWStats.conf file to work with IIS 6.

 

Installing Perl

 

Here’s the direct link to the Perl binary for Windows. http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl

Grab the MSI version. GO ahead and run the install (you may want to reconfigure the location that the installer is targeted to.

 

Once Perl is installed, you’ll need to setup a Web Service Extension mapping in IIS. So, go ahead and open up IIS Manager (start>run>inetmgr), and then point to Web Service Extensions. Right click, and go to Add New Web Service Extension. Give it a useful name, i.e. Perl. Then, click Add, and browse to your Perl binary (Perl.exe). There’s a crucial extra piece here – tagging a “%s” %s on the end. For example: ‘D:\Perl\bin\Perl.exe “%s” %s’.

 

When the Perl installer was run, it should have setup the script mapping in the IIS home directory config, but if not, you’ll have to do that too. Right click the virtual directory/application/website you want to configure the Perl scripts for, go to the home directory tab, and then click Configuration down towards the bottom. If *.pl isn’t in the list, click add, and then put the same command in for executable as you did in the Web service extension (i.e. D:\Perl\bin\Perl.exe “%s” %s’). The extension is .pl, and go ahead and limit verbs to ‘GET,HEAD,POST’. Finally, check off script engine and verify that file exists.

 

That’s in for Perl, PHP should be similar, but I haven’t tried it yet.

 

The AWStats Setup

 

Now that Perl is installed, we can get AWStats all setup. Step one is to make a directory for it somewhere, under wwwroot is probably a good choice. Go into IIS Manager, and make an application out of the directory (click Create on the Home Directory tab). Next to Execute Permissions, select Scripts and Executables from the dropdown.

 

Step two is configuring the AWStats.conf file and IIS logging. Let’s tackle IIS Logging first. Right click the website to be logged, grotto properties, and then on the Configuration tab, check off Enable Logging (if it isn’t already). Select W3C Extended Format from the dropdown, and then click Properties. Select Daily logging, and then point the log files path elsewhere if you like. The Network Service account (or whatever account you configuring your AWStats application to run under will need permissions to this folder).

 

Proceed to the advanced tab and uncheck everything. There are certain items here that we’ll tick back off. Namely, the following items should be checked:

v     Date (date)

v     Time (time)

v     Client IP Address (c-ip)

v     Username (cs-username)

v     Method (cs-method)

v     URI Stem (cs-uri-stem)

v     Protocol Status (sc-status)

v     Bytes Sent (sc-bytes)

v     Protocol Version (cs-version)

v     User Agent (cs(User-Agent))

v     Referrer (cs(Referrer))

 

Once this is done, go ahead and click OK all the way through to get back to the main screen. The next step is to delete all the old log files if they exist, as they’re not in the right format. The IIS end is now done, the final step is to setup the AWStats.conf file.

 

There are only a couple of items that need configuring in the AWStats.conf file for successful operation. The rest are covered in depth in the documentation, so, I won’t discuss them here. The first parameter to setup is your log file item. The only important part is the final piece at the end with the date time codes. For simplicity’s sake, I’ve included the entire line from my config file below:

 

LogFile="H:/Inetpub/LogFiles/W3SVC2024744933/ex%YY-24%MM-24%DD-24.log"

 

The config file and documentation say that one should specify LogFormat=2 for IIS. Unfortunately, IIS 6 does not follow this predefined format, so we’ll have to specify our own:

 

LogFormat="date time cs-method cs-uri-stem cs-username c-ip cs-version cs(User-Agent) cs(Referer) sc-status sc-bytes"

 

(that’s one line that got wrapped a bit)

 

The final parameter I’m going to cover here is DirData. This is a few down from LogFormat. Set this to the directory where you want AWStats to store its’ data files. I set mine to ./data, and place the folder under my AWStats root. Keep in mind, wherever this folder is, Network Service will need write permissions (if you schedule nightly file analysis, whatever account the task runs under will need write permissions).

 

I also have PurgeLogFile set to 1. This tells AWStats to delete a log file when it’s done analyzing it.

 

Scheduling Nightly Log file Analysis

 

AWStats only analyzes log files when told to do so. It can easily be toggled from the command line, and running a scheduled task to do this is the best solution. I have mine configured for 12:05 AM. I have a fairly small log file. For larger files, you’ll need to configure this to start earlier in the evening. Here’s the command my task runs:

 

H:\perl\bin\perl.exe H:\Inetpub\BrianCDesmond.com\wwwroot\awstats\awstats.pl -config=briandesmond.com –update

 

This is one line (wrapped). You’ll obviously need to reconfigure the physical paths to point to your Perl and AWStats installs.

?>

EDIT: With my LogFile config setting, you schould actually schedule AWStats to run after midnight, as it processes the previous day's log.

?>

?>

Published Sep 08 2003, 09:55 PM by bdesmond
Filed under: ,

Comments

 

Scott Galloway said:

Interesting, why do you prefer this to (for example) analog?
September 9, 2003 9:46 AM
 

TrackBack said:

Danny Boyd's Blog
September 14, 2003 8:06 PM
 

Cekkuli said:

Thanx dood. This was really helpfull.

-C
October 8, 2003 3:32 AM
 

Geomon said:

Thanks man. I appreciate you taking the time to put this together!
October 16, 2003 3:54 AM
 

Tymbow said:

Did you try and use Geo-IPfree by any chance - I'm trying to get this working at the moment but no luck.
October 31, 2003 2:14 AM
 

LordReliance said:

Tested with AWStats 5.7, Win2003 and IIS 6:

LogFormat="%time2 %cs-method %cs-uri-stem %cs-username %c-ip %cs-version %cs(User-Agent) %cs(Referer) %sc-status %sc-bytes"
November 3, 2003 1:09 AM
 

Jamie said:

You da man! Thx for your effort!
November 20, 2003 3:34 PM
 

Tommaso Patrizi said:

Thank You a lot ....

I used AWSTATS on my old IIS 5.0 elearning site with great satisfaction and was very sad to leave it because of IIS 6!!!

Now I am much happier!!!

W open source and good programmers that share their knowledge!!!

December 3, 2003 5:21 AM
 

Ernst said:

Excuse me if I am asking this:

I have setup AWStats on my localhost PC and everything works beautifully! I then attempted to install it on a production server which has the Log Files in C:/ and Perl and AWStats installed on the F:/. When I use CLI, everything seems to be fine with -updating the config file. I can also create a -staticlink html file easily.

But this is where I am having trouble: When I try to view these stats view my browser on my PC, the stats do come up, but I can't Update them. I get the following error:

Error: Couldn't open file "F:\cgi-bin/awstats122003.webserver.tmp.3140" for write: Permission denied

Setup ('F:\cgi-bin\awstats.webserver.conf' file, web server or permissions) may be wrong.
See AWStats documentation in 'docs' directory for informations on how to setup awstats.

Trust me, I have tried all kinds of configurations, but nothing so far. The one thing I have tried after all of my configuration changes is Reboot the web server! Do I have to do this? Also, none of the images work, i.e. come up. It comes up on the static .html file that I created via the CLI, but not via the URL on my PC.

Any assistance will be greatly appreciated!
December 4, 2003 10:57 AM
 

fling93 said:

I'm just starting to play around with this as well, and I get that same error when I set purgeLogFile and ArchiveLogRecords to 1. So my guess is that the script doesn't have write permission to either the logfile or the directory to archive to. I tried chmod-ingthe permission of the directory to 777, but it didn't help, so maybe it's really the logfile, but the script is reporting the error on the wrong filename.
December 13, 2003 5:02 PM
 

Darryn Jones said:

Thanks for writing this Brian, it has really helped me.
December 15, 2003 6:38 AM
 

Matt said:

Thanks for posting this. It got my server back up. Why must MS make everything so different when upgradeing? Thanks much for the info!
December 16, 2003 3:18 PM
 

Dinos Cyprus said:

Question on how to set up Perl on IIS
December 24, 2003 6:41 AM
 

Ignacio Diaz said:

Your instructions of configuring PERL in IIS6 are very clear and they really work.

I used your instructions to install "Quizfaber", a freeware java program to make web quizes. You can check it out at:
http://www.lucagalli.net/index.html
I recommend it, if you need to make any type of web aware test.

:-)
thanks I appreciate it.

iggy
January 8, 2004 4:30 PM
 

IZnogoud said:

Thx a lot for the tips all :-p
Great work and help :-)
IZ.
March 3, 2004 6:44 AM
 

ben said:

Yup, works, thanks a lot!!! \o/
March 11, 2004 9:27 AM
 

Simon Schofield said:

Thanks for the tips Brian. Full credit to you because I have managed to write a PDF document explaining a step by step process of installing AWStats on IIS 6.0 at <a href="http://www.ihsen.com/support/InstallingAWStatsOnIIS6.pdf">www.ihsen.com/support/InstallingAWStatsOnIIS6.pdf</a>. I've included diagrams as well. This would not have been possible without your writings. Cheers! Simon
July 21, 2004 2:53 AM
 

Simon Schofield said:

If only I was clever enough to realise that posting a link to this page does not require the "A" tags before posting... Shall I try again?
http://www.ihsen.com/support/InstallingAWStatsOnIIS6.pdf
July 21, 2004 2:57 AM
 

Prem said:

Thanks Brian,

THe LogFormat tip worked for me with the logresolvemerge program.

November 14, 2007 2:37 PM
 

John Gregory said:

Thank you Brian and Simon!!!

Question - after reading 'everything' I cannot find answer anywhere.

We moved domains from Win2000 to Win2003 Server. After moving LogFiles into Stats directory, AWStats does not recognize. Is this LogFormat issue you mention above?

December 12, 2007 1:22 AM

Leave a Comment

(required)  
(optional)
(required)  
Add