Getting AWStats installed and configured on IIS 7.5

One of things I’ve wanted to evaluate is AWStats for doing analytics on a variety of sites I run. AWStats ( is a free Open Source (Perl based) package. One of the things I couldn’t find that covered the steps to get IIS 7.5 up and running.  I’m still working on a few config items within AWStats, which if you have suggestions, please let me know.

Here is the order of what I did to get my server up and running. I’ll assume you have a Windows Server 2008 or 2008 R2 server with IIS Installed.   If you have any further questions, comments please feel free to add to the article. 


  • Download, Install ActivePerl
  • Download AWStats
  • Setup DNS (Optional)
  • Setup IIS Site
  • Configure App Pool as 32 bit
  • Setup Perl Handler, approve isapi
  • Setup AWStats conf files.
  • Enable frequent updates
  • Misc things


Download, Install ActivePerl

The first thing you’ll need is a method to run PERL on Windows. Thankfully, ActiveState provides an x86 and x64 Perl implementation. From my testing, I can only get the x86 edition running within IIS. For purposes of this article, download and install the x86 (32 bit) edition of ActiveState. Later in the article, we’ll configure IIS.

I installed ActiveState (32 bit ) to C:Perl   If IIS is installed, you’ll want to confirm if the HTTP Handler is already setup.  If not, I’ve included a command later in the article how to setup. 


Download AWStats

The next step, download and extract Awstats. The current version available is AWStats 7.0. Go to , download and extract somewhere on your system.


Setup DNS (Optional)

For my purposes, I setup a single separate websites to access my stats.  The link I used is in the format below to access various domains. I setup an A record called Stats in DNS.<DomainName1><DomainName2>


Setup IIS Site

I’m going to take assumptions on folder names for this article, you can adjust them to fit your environment.

1) Create a folder in ‘mkdir’

2) In the AWStats extracted files, copy all folders in the ‘wwwroot’ to

These folders will store the various domains stats.

a) create a folder called c:inetpubstats.example.comstatsDomain1
‘mkdir c:inetpubstats.example.comstatsdomain1’

b) create a folder called c:inetpubstats.example.comstatsDomain2
‘mkdir c:inetpubstats.example.comstatsdomain2’

Create a IIS site with Internet Manager or AppCMD, for this article, I’ve provided AppCMD commands

‘Create app pool

C:WindowsSystem32inetsrvappcmd add apppool /

‘Set App Pool to integrated mode. This can be v2.0 or v4.0

C:WindowsSystem32inetsrvappcmd set config /section:applicationPools /[name=’’].managedPipelineMode:Integrated

‘Add site

C:WindowsSystem32inetsrvappcmd add site /id:12345 / /bindings:http/*:80: /

‘Assign app pool to the site.

C:WindowsSystem32inetsrvappcmd set app / /”

‘Set to 32 bit mode

C:WindowsSystem32inetsrvappcmd set config -section:system.applicationHost/applicationPools /[name=’’].enable32BitAppOnWin64:”True” /commit:apphost


‘Setup Perl Handler, approve isapi

Through IIS Manager, go to Internet Manager

  • Click on Website
  • IIS Section
  • Handler Mappings
  • Add Script Map
  • Request Path – *.pl
  • Executable – C:PerlbinPerlEx30.dll
  • Name – Perl
  • Click OK

When prompted for this, go ahead and click Yes. This attribute sets at a server level.


Configure Perl Handler

c:windowssystem32inetsrvappcmd.exe set config “” -section:system.webServer/handlers /[name=’PERL’].name:”PERL” /[name=’PERL’].path:”*.pl” /[name=’PERL’].modules:”IsapiModule” /[name=’PERL’].scriptProcessor:”C:PerlbinPerlEx30.dll” /[name=’PERL’].resourceType:”Unspecified” /[name=’PERL’].requireAccess:”Script” /[name=’PERL’].preCondition:”bitness32″


Setup AWStats conf files.

I’m going to defer to the AWStats FAQ section configuring the conf files. A couple things I did

0) Make a copy of the awstat.module.conf to (awstats.StatsExampleCom.conf)

1) make sure to set the DirData attribute is “DirData=”c:/inetpub/″”

2) Follow the AWStats FAQ, check out the Demo / ScreenShots section. They set a few attributes.

3) I learned NOT to do Reverse DNS lookup, that really slows down.

4) You might need to adjust permissions on the IIS Logs folders you are reading, it’ll depend on which account you run the application Pool run as. By default, the IIS Log folders only grant permissions to Administrators and SYSTEM. You could either setup the app pool to run as a specific account, or use ApplicationHostIdentity. What I did was use the default account, ApplicationHostIdentity.  I’d suggest using Process Monitor (by sysinternals)

Here are the attributes I updated so far, this could change as I learn more about AWStats

LogFile=”c:/inetpub/logs/logfiles/w3svc1/u_ex%YY-0%MM-0%DD-0.log”  (You might need to tweak this setting)
HostAliases=”localhost REGEX[$]”

Enable frequent updates

I setup a batch file and put the following commands, then I scheduled to run frequently as an account (Administrator) to access the IIS Logs. You could also run the scheduled task as SYSTEM.

Here is the command, it assumes the file is named awstats.DomainName1.conf and will reside in c:inetpubstats.example.comcgi-bin folder

perl -config=<DomainName1> –update


Misc Things – Here are a few lessons learned.

Use the script to create a single file or several files to import to AWStats. I found if you have very large (many MB or GB), you’ll need to take an approach of having smaller files. I didn’t find an automated way when importing existing files. So in my example, I created a few files, would import into AWStats, this require you update the awstats.example.conf file, run the perl –config=Example –update over and over. It was a little clunky, but seemed to work.

Here is the command I ran

C:inetpubstats.example.comtools>perl c:inetpublogsLogFilesW3SVC5*.log > StatsExampleCom.log

When creates an import file, it doesn’t have the IIS Headers created in the log files, you’ll need to add the IIS headers like your website and awstats.example.conf is setup. What seems to work for me is 1) Create a blank file with just the headers, then run the command below, notice the two arrows. “>>” This forces the command prompt to append, then you can run the import.

C:inetpubstats.example.comtools>perl c:inetpublogsLogFilesW3SVC5*.log > StatsExampleCom.log

Doing one-time imports files

Add IIS Logs headers to the new one time import files

Create a file, add headers

#Software: Microsoft Internet Information Services 7.0

#Version: 1.0

#Date: 2023-05-18 00:01:55
#Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Cookie) cs(Referer) sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken

HTTP Error 502.2 – Bad Gateway

I got this error below when I tried using the x64 bit version of ActiveState. I found a few errors posted on the website with no resolution. I’m not sure if the posts were trying x86 or x64.

HTTP Error 502.2 – Bad Gateway

The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are “”.