Before install this monitoring tools, we need
- The Perl to be installed, download it from the official site( either active or strawberry MSI file).
- Add module CGI: open server role, right click the IIS server, add role, check the CGI under “Application development”:
- then we need to tell IIS to execute the .pl file by add the script map.
Open Internet Information Services Manager and open the Handler Mappings interface. Click on the action, “Add Script Map”.
To allow IIS to execute Perl script files (.pl), configure the new script mapping with the following settings:
- Request path: *.pl
- Executable: C:perlbinperl.exe “%s” %s (where ‘C:perl’ is the location where you extracted the Perl binaries)
- Name: Perl-pl
In the Request Restrictions dialog, set the Verbs tab to allow the following: GET,HEAD,POST.
Apply all changes.
When creating the new script mapping, IIS will ask you if you want to allow this script mapping to run as a CGI application. Answer ‘Yes’ to the dialog.
Additionally, if Perl scripts will be deployed as CGI files (.cgi), a script mapping will need to be configured for this file type as well:
- Request path: *.cgi
- Executable: C:perlbinperl.exe “%s” %s
- Name: Perl-cgi
- Verbs: GET,HEAD,POST
Once finished apply your changes and select ‘Yes’ when IIS prompts you to confirm running the script mapping as an application.
Once you have configured IIS to run both file types, they will be listed in your Handler Mappings.
To configure logging in IIS 7, open IIS Manager and select Logging from the server configuration options.
In the Logging configuration, set up a single log file per site which rolls over daily using the local time for file naming.
Click the Select Fields button and check the boxes next to the required fields.
Apply your changes.
Setting Up AWStats
Download the AWStats zip package from Sourceforge. Create a folder called ‘awstats’ in your ‘C:\inetpub\wwwroot’ folder and extract the following files from the downloaded zip file to this folder:
Once the files are extracted, copy the “awstats.model.conf” file to a file named “awstats.domain.com.conf” (where domain.com is the site to track), open it in Notepad and configure the options as needed.
The first thing you will need to configure is the log file location, which by default is located here:
- Server 2003: C:\WINDOWS\system32\LogFiles\W3SVC[IIS_ID]
- Server 2008: C:\inetpub\logs\LogFiles\W3SVC[IIS_ID]
You can find the IIS ID by looking at the master site listing in IIS Manager and noting the value in the ID column next to the respective site.
Set the options in the configuration file. This file has a very good explanation of what each option does, so take a few minutes to review them. Here are a few settings of interest according to the setup above:
(Server 2008/IIS 7 where the stats are calculated daily)
Change the LogType value to “W” for analyzing web log files
- LogFormat=”date time cs-method cs-uri-stem cs-username c-ip cs-version cs(User-Agent) cs(Referer) sc-status sc-bytes”
- DefaultFile=”index.php index.html”
Set the AllowToUpdateStatsFromBrowser parameter to 1 if you don’t have command line access and have only cgi access.
Once you have saved your configuration file, run the AWStats Perl Script to compile the stats data. The command looks like this:
C:\inetpub\wwwroot\awstats>C:Perl\bin\perl.exe awstats.pl -config=domain.com
The above command assumes the following (configuration used for this article):
- The folder “C:inetpubwwwrootawstats” serves the stats through IIS.
- Perl was installed to the “C:Perl” directory.
- The config file is named “awstats.domain.com.conf”.
Finally, you can access the stats data through your browser. This URL is publically available for anyone to view unless you configure security via IIS. To test our configuration, just browse to: