So, you want AWStats on IIS7? This doesn’t require a restart of IIS, so it can be done in place with no issues.
For IIS6, you will need to look elsewhere sorry. I’m also sorry you still have to deal with IIS6.
The 2 Required Files
Accept the agreements, etc.. until you come to the Custom Setup screen
I have removed the Docs and the Examples.
I have unticked the create IIS virtual directory as it’s not needed.
This is important: When it has finished installing, LOG OUT of (or even better, reboot if you can) the system.
Logging out and back in will allow the system to pick up the new PATH that was modified by the ActivePerl install.
Use the default directory, and click Install
If you get an message stating that no Perl is detected:
Make sure you installed ActivePerl, and
Log out and log in again, or
Restart the machine
You will be presented with this; a command prompt. This is going to set up your default config file for your domain.
It will try to detect Apache, but you don’t want that.
So type "none”
It is asking you to create a new config file.
Enter in your domain name e.g. mydomain.com
The config still needs to be set up properly, but for now we will create the website and the config after that.
Creating an IIS7 site
Create a new site through INetMgr (the standard IIS manager)
I have un-ticked “start web site immediately”, but this may not be important. You will have to restart this site once it is configured properly.
Your settings can be different to these, but I have changed the default port to a random port (e.g. 1388) so this site is neither running as the default site, nor visible to the public as our firewall blocks this port.
For this website (awstats), go to the “Handler Mappings”
Click “Add Module Mapping”.
Set it up as I have here:
Request Path: *.pl
Click Yes. You do want this to be allowed.
64 bit Machines only:
Make sure the site’s application pool is set to “Enable 32 Bit Applications”
Start up the website. You may need to start the application pool as well.
Moving the AWStats site into place
Go to your AWStats install folder
(mine is C:Program Files (x86)AWStatswwwroot )
Copy these folders and files to your website folder (C:inetpubawstats)
Go to your site in a browser to see if you are good to go:
You SHOULD get an error like this:
Error: Couldn’t open config file "awstats.localhost.conf" nor "awstats.conf". Please read the documentation for directories where the configuration file should be located.
If you do, be happy. We can move on. If you don’t, leave me a comment and I can try to help you out.
Getting The Right Information From the Target Site
You will need to get this information from your site that you wish to analyse:
1. The location of your log files
This is typically C:inetpublogsLogFilesW3SVC + the ID of the site. Hint: The ID can be found in the INetMgr where the sites are listed.
2. The name of your log files
Is the name u_ex or just ex? Maybe something different altogether.
3. The format of your log files
In one of the log files that are in that folder, there is a line at the top you will need to copy:
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
Setting up the Config and Linking to the Logs
If you go to your website folder and have a look in the cgi-bin (C:inetpubawstatscgi-bin) you will see a file called awstats.mydomain.com.conf
Open this in your favourite text editor. You will need to change a few things:
will need to be replaced by the location of your log files for IIS7.
For “u_ex” names:
LogFile=”[PATH TO YOUR LOG FILES]u_ex%YY-24%MM-24%DD-24.log”
The funny bit at the end is actually matching the log to the day (or more accurately, the previous day) the report runs. This means your report generation will need to be run at least every day.
You need to now set the format in which AWStats reads the files
And replace this with (using the example format taken from the log file I used)
LogFormat= “date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken”
NOTE: This is not the optimal log file format setup for AWStats.There is guide at sysadmin geek that can help with setting up optimally, with data transfer and referrer logs. To do this you will need to change the IIS log settings to provide different data. The reason I’m leaving that out for now is that I want this to be an easy setup. You can change things after you have got it working!
Find HostAliases and add in all aliases associated with this site.
HostAliases="mydomain.com http://www.mydomain.com 127.0.0.1 localhost"
From a security standpoint, there are some other settings you can play with, but they are not going to be looked at deeply here. Examples are :
Running the first report generation
It comes down to this.
Start up a command prompt, and run:
Perl awstats.pl –config:mydomain.com –update
This should start reading the Log files. When it is finished, go to the site in a browser:
If you see some numbers, congratulations!
Setting up the Scheduled Task
Now you have to run this every day, as the system does not automatically update.
I won’t go into detail here as there are many sites on setting up Scheduled Tasks in the Task Scheduler, but this is the screen shot of my settings:
Conclusion & Things You May Want To Do
So that is how to set it up. Any queries and / or suggestions, let me know.
Do you want better stats with referrers and search engine queries?
Trying to set up better reporting by changing IIS Log settings. There is a good guide at sysadmin geek with all the settings.
Do you want to parse old log files from months before?
There is a way to do this by specifying log files specifically, or by merging log files and then reading that merge specifically. This can be be done by specifying the file name in the config. You can use a tool included with awstats called “logresolvemerge.pl” to merge the log files, which can take a while for multi gig log files.