AWStats on IIS7 (in less steps than the closest cup of coffee. Well almost. )

image

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

  • ActiveState ActivePerl – http://www.activestate.com/activeperl
  • AWStats Installer (awstats-7.0.exehttp://awstats.sourceforge.net/#DOWNLOAD
  • Installing ActivePerl

     

    image

    Accept the agreements, etc.. until you come to the Custom Setup screen

    image

    I have removed the Docs and the Examples.

    image

    I have unticked the create IIS virtual directory as it’s not needed.

    image

    Click Install.
    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.

    Installing AWStats

    image

    image

    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.

    image

    It will try to detect Apache, but you don’t want that.

    So type "none”

    image

    It is asking you to create a new config file.

    Type “y”

    image

    Enter in your domain name e.g. mydomain.com

    image

    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)

    image

    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.

     

    image

    For this website (awstats), go to the “Handler Mappings”

    image

    Click “Add Module Mapping”.

    image

    Set it up as I have here:

    Request Path: *.pl
    Module: IsapiModule
    Executable: C:PerlbinPerlEx30.dll
    Name: Perl

    image

    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”

    image

    image

    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

    image

    (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:

    http://localhost:1388/cgi-bin/awstats.pl

    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.

    image

    2. The name of your log files

    Is the name u_ex or just ex? Maybe something different altogether.

    e.g. u_ex101110.log

    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

    image

    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:

    LogFile="/var/log/httpd/mylog.log"

    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

    Look for

    LogFormat=1

    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 :

    AllowAccessFromWebToAuthenticatedUsersOnly=0
    AllowAccessFromWebToFollowingIPAddresses=""

    Running the first report generation

    It comes down to this.

    Start up a command prompt, and run:

    cd C:inetpubawstatscgi-bin
    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:

    http://localhost:1388/cgi-bin/awstats.pl?config=mydomain.com

    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:

    image

     

    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.

  • Advertisements

    25 thoughts on “AWStats on IIS7 (in less steps than the closest cup of coffee. Well almost. )

    1. Hi there,

      I appreciate your precise and concise steps to setup awStats.

      And, I manage to setup as per your steps until the stage

      http://localhost:1388/cgi-bin/awstats.pl?config=mydomain.com

      If you see some numbers, congratulations!

      I really can see the numbers. But I can see only links from 1388 or something like this.

      I cannot see links from other websites or search engine, I cannot also see hosts that link to my website.

      Could you help?

      Thanks,
      Richard

      Like

    2. Hi,

      I tried to install awstats the way you explained and when i do the step of “Running the first report generation”

      As soon as go c:inetpubawstatscgi-bin>perl awstats.pl -config=<> -update
      it gives me an error
      Create/Update database for config “./awstats.<<mydomain.com.config" by AWStats version 7.0 (build 1.971)
      from datain logfile "/var/log/httpd/mylogs.log"…
      Error: Couldn't open server log file "/var/log/httpd/mylog.log" : No such file or directory
      Setup ('./awstats.<>.com.conf’ file, webserver or permission) may be wrong.
      check config file, permissions and AWStats documentation (in ‘docs’ directory).

      —Please let me know what has to be done for me to get my numbers. Your help is greatly apprecieated.

      Thank you,
      Prathyu

      Like

    3. This helped a lot. I now have AWStats coming up in my browser for my Intranet using: http://intra/cgi-bin/awstats.pl?config=intra

      However I’m getting all zeros! I’m sure my path to my LogFiles are correct ie)
      LogFile=”C:/inetpub/logs/LogFiles/W3SVC2/u_ex%YY-24%MM-24%DD-24.log”

      I’ve followed the instructions here carefully. I’ve also set the SiteDomain to the name of our server.

      Anything I might be missing?

      Thanks

      Like

      • I haven’t done this for a while, so sorry I am not sure. It was tricky, and it might be easier to do it again and see if it works. Sorry that is not much help probably.

        Like

    4. could you please help me to get log format of this:

      2013-03-19 23:59:30 174.29.71.96 GET “http://www.wipo.int:80/export/sites/www/madrid/en/fees/xls/fees.xls” 200 1337824 4.142 – 720 “Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0.2) Gecko/20100101 Firefox/10.0.2” “http://www.wipo.int/madrid/en/fees/” – “” “1337344” Success 480 “” “” “” “”

      2013-03-19 23:59:58 206.190.75.9 GET “http://www.wipo.int:80/sme/en/documents/pdf/technology_transfer.pdf” 200 21003 0.107 – 477 “Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22” “https://www.google.com/” – “” “20502” Success 501 “” “” “” “”

      Like

    5. Are you able to provide a screenshot of what a example log file looks like? This looks like an excellent solution, my concern is if it’s able to show users and IP addresses of who is contacting the server – I use IIS & WebDAV to give people access to files remotely. I imagine I would see the files with GET verbs all over the place. Is this accurate?

      Like

    6. For Windows Server 2008 R2, the following changes had to be made in order to get the scheduled task to work properly:
      C:[PERL folder]perl.exe C:[Path to AWstats]awstats.pl -config=mysite -update

      For the scheduled task properties as it relates to my site, it was:
      Actions: Start a program
      Program/script: C:Perl64binperl.exe
      Add arguments (optional): C:inetpubwwwrootawstatsawstats.pl -config=mysite.com -update

      I ran the task on-demand and everything updated properly.

      Like

    7. Very nice instructions, thanks!

      Is there a way to wipe out previously loaded data?
      maybe something like

      perl awstats.pl -clean
      or
      perl awstats.pl -clear

      Like

    8. One more thing, the only problem I had with the instructions was this:
      My IIS server is running Windows X64.
      So it made sense to me to try to install the X64 version of Perl, but that didn’t work.
      I had to install the x86 version of Perl.

      thanks again.
      Seth

      Like

    9. Excellent article.. I was able to setup my awstat in less than an hour using your well documented template! I was also able to get 5 year worth log files parsed using the setting –
      LogFile=”/cygdrive/e/awstats-7.2/tools/logresolvemerge.pl /cygdrive/c/Logs/W3C_LogFiles/W3SVC1/*.log |”

      Thank you so much for writing this up!

      Like

    10. Hi

      Thanks for the perfect guide, can you please tell us the easy steps to configure the GeoIP city database plugin with awstats?

      Thanks

      Abdul Raheem

      Like

      • I’m sorry I think that there is error in the the web.config file

        I’ve correct the problem but now, I’ve the following error:

        The website cannot display the page

        Like

        • Hi Sophie
          I think that the problem It’s in the hanlder mappings.

          In this guide, there are two problem:

          1) use the equal symbol—-> Perl awstats.pl –config=mydomain.com –update
          2)Under the Connections tab on the left click on your computers name. Then double click “Handler Mappings”
          Under the Actions tab on the right click “Add script map”
          Request path: *.pl
          Executable: c:Perlbinperl.exe “%s” %s
          Name: Perl Script (PL)
          Click OK
          Click Yes on the “enable ISAPI message”
          For people running 64bit Windows like me you’ll get an error saying illegal characters. Enter the executable as just “c:Perlbinperl.exe” and we’ll correct this later.
          Click “add script map” again and enter:-
          Request path: *.cgi
          Executable: c:Perlbinperl.exe “%s” %s
          Name: Perl Script (CGI)
          Click OK
          Click Yes on the “enable ISAPI message”

          For me It’s work

          Like

    11. When I go to the site in browser, I have the following:
      an unhandled win32 exception occurred in w3wp.exe[some_number]

      Does anyone can help ?

      Like

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s