How to setup, install and configure awstats with Apache and Windows

For the purposes of this guide, I will assume the installations of the software are installed in the following directories to keep this guide simple and easy enough to understand for configuration. If you are stuck or not sure at any point, you can always refer to the awstats online guide

Apache : c:\Apache2.2
awstats : c:\awstats

The guide I used to use before I started learning it myself to understand it better was located at the apply named Pizza by the Slice Website which was an article written by Buzz Carter. It's a useful guide, but I was having minor problems with configuration of my website so decided to research it further and develop it myself and understanding the software better so I could learn how to fix it in the future. Once you get your head around things it's actually relatively simple on how it works. This guide was written by myself, I give credit to Buzz as his site helped get me started, but all the other content on here was written by myself so wish to be credited as the author if you use my site as the reference for this material as I've taken a long time to make this step by step as detailed as possible and I've carried out a lot of trial and error to make this guide have the full information you require to have a fully configured site working with awstats

Pre-requesites for usage of awstats with Apache and Windows

  1. You will need to have PERL installed on your computer before you do the below configurations.
  2. Awstats directories will need to be setup and created for any specific files (logs, database, html, etc)
  3. Your apache must be configured correctly in the httpd.conf for the access_log and error_log files to match up with correct logging criteria to be used to generate the reports {I will create a guide for this at some stage}

Installation of awstats

  1. First, go to the awstats website and download the awstats zip file
  2. Extract the contents of the zip file into the folder c:\awstats, retaining the folder structure - create the folders HTML, LOGS, and DATA

Generating your site configuration file

  1. Once you have installed the files required for the software, you will need to generate a configuration for your website
  2. Open up a command prompt in windows and type the following (if your directories are different modify the paths)
  3. cd c:\awstats\tools and press enter - this will take your to the root of the directory holding the awstats configuration file
  4. When you are in this directory, type perl
  5. A configuration script will run, you will be required to enter 3 things for your website - it will ask you to generate a new configuration, type Y then enter
    • Enter the path to the apache directory - this will be c:\Apache2.2 - press enter
    • Enter the path to the apache configuration file and directory - this will be c:\Apache2.2\conf\httpd.conf - press enter
    • Enter a website configuration file name, enter your domain name (e.g - I intially gave mine a different name, but it appears the configuration file name is used when viewing stats live in your browser. So keeping it to match your name easily identifies it too
  6. Let the scripts run and a basic configuration file called will be stored in the wwwroot\cgi-bin folder

Configuration of the "mysite" awstats file

  1. When the above step has finished you will need to open up the file you have just created in a text editor. My personal choice is Notepad++
  2. Look in the file and modify the values for the section "logfile" - change this to " c:/Apache/logs/access_log_%DD-24-%MM-24-%YY.log "
  3. You will need to modify this value if the apache access logs are not called access_log_DD-MM-YY.log depending on your httpd.conf file. If they are not called this you can easily modify this section if you are unsure on what the filenames are called
  4. Search for a section called "DirIcons", change this value to "c:/awstats/wwwroot/icon" {required or graphics missing when you generate report}
  5. Search for the option called "DirData" - modify this value to be "c:/awstats/data" - this is where awstats stores it's data to generate the reports
  6. Save the file, all the other configurations should have been specified correctly when you ran the setup file on the intial configuration

Updating the site database

  1. Open up a command prompt
  2. Type in the command cd c:\awstats\wwwroot\cgi-perl then press enter
  3. Type the command perl -config=mysite -update then press enter
  4. The site update will run and then import the latest data from the apache logs into the database
  5. An example command would be " perl -update "

Generating the intial HTML combined output report for site

  1. Open up a command prompt after doing a database update
  2. Type in the command cd c:\awstats\wwwroot\cgi-perl then press enter
  3. Type in the command prompt perl -config=mysite -output -staticlinks >c:\awstats\html\awstats.mysite.html then press enter
  4. After this has ran a report will be generated and stored in the c:\awstats\html folder called awstats.mysite.html which can be opened in a web browser to view static data for the website (for full information on each section you need to use the file)

Generating static pages for each individual file report

Still researching this one - at the moment I just use a compiled report - when I work it out I'll update the process on this log. Everytime I ran the multiple month patch it was generating a full set of reports, but the HTML reports were blank with no data stored inside them. It was also constant opening my Notepad++ editor when generating each individual report and I had to close it before it would create the next which I found very annoying. So there's a couple of bugs I need to work out before I can continue doing the rest. I intend on using the multiple month patch once I have this worked out so I can go through different sets of data at a glance. I also have the day by day patch installed from Internet Officer website for reviewing all of my stats per month on a daily status

Automating awstats updates for website

  1. Firstly, you will need to create two batch files for your database update + HTML report generator
  2. The content for each of these files are as follows..
    • Database Update File (give it a filename to identify for example Database Update.bat) needs to end in .bat
    1. cd c:\awstats\wwwroot\cgi-bin
    2. perl -config=mysite -update
    • HTML Report File (give it a filename to identify for example HTML Report Output.bat) needs to end in .bat
    1. cd c:\awstats\wwwroot\cgi-bin
    2. perl -config=mysite -output -staticlinks >c:\awstats\html\awstats.mysite.html - this will generate the new HTML report
  3. To automate the process so you don't have to type commands each time you want to generate the reports you can use Windows Task Scheduler
  4. Open up task scheduler through the start menu (start > programs > accessories > system tools > task scheduler)
  5. Go to the actions menu in the top right and select Actions > Create Basic Task then press enter
  6. Give it a file name to identify the file such as Database Update Process (note: dbase update must always be first) as it imports the new data into the file used to generate the HTML report. Give a description if you'd like to remember it's function - then press next
  7. Select the option for daily then click next - select a start time to run it I set mine for 00:15:00 recurring every 1 days - then click next
  8. Enter the process to use - select start a program - click next browse to the batch file click next
  9. Select finish and the process will be added to run at 00:15 every day until it's stopped
  10. Repeat this process creating a seperate task for generating the static HTML report. I set mine as a start time for 00:30:00 so it allowed time for apache to rotate the log files. Otherwise it would cause an error when generating the reports or outputting them