Installing AWStats under WAMP (Windows/Apache/Perl) — Linux, too

Resources and Downloads:

Sections on this page:

Basics: Installing AWSTats

Know Where Your Stuff Is

my AWStats installation

First off, it makes no difference whether it’s Windows or Linux, your succeess or failure is almost entirely dependent upon this: knowing where things are.

I’ve no other more useful advice, organize first, then slowly you’ll learn where AWStats expects things to be. Odds are that you’ll not get everything correct on the first go.

top of page

The Directories

I’ve installed this on WAMP and LAMP, but this example is my local Windows development box, this frees me from security issues of leaving logs and all other files accessible from a public web server. Once it works on my test box, I’ll set it up for the Linux server. At right you’ll see the default AWStats directories and those I’ve added (mine, cleverly, are all prefixed with "my")

  • unzipped the AWStats files and moved them into "myAWStats".
  • mydata, where AWStats will be saving it’s summary files
  • myhtml, where I want AWStats to place its generated reports
  • mylogs, where I’ve copied all of the server logs

My config file for this setup lives here:

and is called:

top of page

Apache httpd.conf

If you’re only going to run this via cron job (not real-time CGI) you probably can skip this, or if you used an installer there’s a decent chance this was added automatically. Here’s the new stuff for your Apache configuration file:

Also, in the config files you’ll be creating for your site you’ll have an opportunity to override this.

  1. #
  2. # Directives to allow use of AWStats as a CGI
  3. #
  4. Alias /awstatsclasses "G:/myawstats/wwwroot/classes/"
  5. Alias /awstatscss "G:/myawstats/wwwroot/css/"
  6. Alias /awstatsicons "G:/myawstats/wwwroot/icon/"
  7. ScriptAlias /awstats/ "G:/myawstats/wwwroot/cgi-bin/"
  9. #
  10. # This is to permit URL access to scripts/files in AWStats directory.
  11. #
  12. <Directory "G:/myawstats/wwwroot">
  13.     Options None
  14.     AllowOverride None
  15.     Order allow,deny
  16.     Allow from all
  17. </Directory>

top of page

Some Batch Files

To simplify testing I’ve created three batch files (later one will become the basis of our cron job):

  • build-first-analysis.bat
  • build-basic.bat
  • build-all-pages.bat

Below are the batch files (note: the text all goes on one line, it’s broken here to fit my too-damned-skinny page, sorry)

perl G:\myawstats\wwwroot\cgi-bin\ -update
perl G:\myawstats\wwwroot\cgi-bin\ -output -staticlinks 
   > G:\myawstats\myhtml\
perl G:\myawstats\tools\ 
   -update -awstatsprog=G:\myawstats\wwwroot\cgi-bin\ 

Finally, run (from command line) the above batches (OK, skip build-basic as build-all-pages covers it) and the web pages are correctly generated (see DOS/command window output below). AWStats — I loves ya. Time to break things.


G:\myawstats>perl G:\myawstats\wwwroot\cgi-bin\ -update

Update for config "G:\myawstats\wwwroot\cgi-bin/

With data in log file "G:\myawstats\mylogs\www.20060106"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 4038
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 4038 new qualified records.


G:\myawstats>perl G:\myawstats\tools\ -update 

Launch update process : "G:\myawstats\wwwroot\cgi-bin\" -update -configdir=
Build main page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output
Build alldomains page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=alldomains
Build allhosts page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=allhosts
Build lasthosts page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=lasthosts
Build unknownip page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=unknownip
Build allrobots page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=allrobots
Build lastrobots page: "G:\myawstats\wwwroot\cgi-bin\"  -staticlinks -output=lastrobots
Build session page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=session
Build urldetail page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=urldetail
Build urlentry page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=urlentry
Build urlexit page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=urlexit
Build osdetail page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=osdetail
Build unknownos page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=unknownos
Build browserdetail page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=browserdetail
Build unknownbrowser page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=unknownbrowser
Build refererse page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=refererse
Build refererpages page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=refererpages
Build keyphrases page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=keyphrases
Build keywords page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=keywords
Build errors404 page: "G:\myawstats\wwwroot\cgi-bin\" -staticlinks -output=errors404
20 files built.
Main HTML page is ''.

top of page

Improvements: Installing Mulitple-Month Patch

If you’re curious what all of the gnashing of teeth is about, here ya go: AWStats, as it runs by default, analyzes only the current month. It keeps summaries of past months, and you can edit the config file to show other date ranges (it’s a danged good program), but to experience the convenience most clients expect (see image at right) you need to do a bit of rejiggering of files. The end product is worth it though. A drop down list showing all available years and months of analysis! So download the patch and let’s go!

Unzip the Patch

Unzip the patch from and you’ll see these 7 files:

From the included README (no .txt, grrrrr):

  This is a patched version of awstats (, so the "Reported period" drop down box is
  available on the generated static pages.

  1) Modify and to suit your
     ($DIRCONFIG, $wwwroot, $folder, $AwstatsProg, $AwstatsProg)

     The generated static pages are saved in $wwwroot/$domain/$folder - so
     each domain have its own folder

  2) Replace the original with the from this
     tarball or even better place it in a folder outside the webscope.
     (Replace the original (in the webscope) with

  3) Use to initially generate the stats.

  4) Set up a cron job that uses to update the
     stats on a regular basis.

OK, let’s tweak the files as described above. Here’s my settings for both and

my $DIRCONFIG  = 'G:\myawstats\wwwroot\cgi-bin';
my $wwwroot    = 'G:\myawstats\myhtml';
my $folder     = '';
my $AwstatsProg= 'G:\myawstats\tools\';
my $Awstats    = 'G:\myawstats\wwwroot\cgi-bin\';

top of page


Moving Files

OK, from my read we have 4 Perl files and one PHP. Where do they go? Here’s where I put them:

Warning! You’re about to overwrite some files. At this point your install is working, backup these files! (,, &

All backed-up? Good. Here’s where I put the files:

  • » G:\myawstats\wwwroot\cgi-bin
  • » G:\myawstats\tools
  • » G:\myawstats\tools (guess)
  • » G:\myawstats\tools
  • index.php » G:\myawstats\myhtml (I think, thanks, anonymous forum poster)

top of page


New Batch File

Going to modify build-first-analysis.bat, just replacing


I ran this and … got an error. Turns out you only need to call the program with a list (separated by spaces) of the domains to be analyzed. The new file is multi-build-first-analysis.bat.

perl G:\myawstats\tools\

Run this and check the myhtml directory to discover — a new sub-directory, named "" (see diagram below). And under here are monthly builds, the magic drop-down allowing me to choose month or year!. I’m there (almost).

So this did our initial run. To maintin this we’ll be calling Here’s the options:

----- awstats_updateall 1.0 (build 1.11) (c) Laurent Destailleur -----
awstats_updateall launches update process for all AWStats config files (except
awstats.model.conf) found in a particular directory, so you can easily setup a
cron/scheduler job. The scanned directory is by default 

Usage: now [options]

Where options are:
  -excludeconf=conftoexclude (Note: awstats.model.conf is always excluded)

So now the simplest bat file, multi-build-all.bat, just reads all of the available configuration files (which we’ve told the script lives in our cgi-bin).

perl G:\myawstats\tools\ now

And believe it or now, we are done! This works! You might want to alter your mod-rewrite rules to make the files easier to access, or create a few strategic index.htm’s that point to the appropriate subdirectories.

I’m analyzing logs for three or four servers, so the multi-year, multi-domain features please me now end.

Good luck with your install!

top of page

Running AWStats for multiple log files

It’s likely, now that you have AWStats running, that you want to process lots of old log files (particularly those of your who’ve just installed the multiple-month-year patch). And you’re thinking, "no problem, I know where that "LogFile" parameter is in the config". Well, something you should know: awstats keeps a pointer to the last record (date/time) it read. (this is part of the data it keeps in those text files under the "mydata" directory; for example).

Say you run AWStats against your November 2002 logs, followed by March, 2003 logs, and then try to run December, 2002, AWStats will find nothing to do. As far as it’s concerned, it’s current up through March of ’03.

Fortunately (or naturally) they’ve thought of this and included a script that will read a bunch of log files and re-order them by date. Exactly what AWStats wants to see.

All you need to do is pop open your config (in my case, (code below is one line):

     G:\myawstats\mylogs\access.log.2006-02-* |"

The script will read all of my January 2006 logs and hand off the results to ASWtats when I call my mulit-build-first-analysis.bat.

I, being paranoid, babysat the first few runs, but it ran just fine. Took a half-hour or so to bash through three years of logs.

top of page

Config options: ignore directories, combine a mulit-domain site

OK, you can get this info anywhere, I did. But since you’re here (and this site is my own PostIt Note) here’s more. Below are some of the interesting bits from my config file.

Because Charles (of fame) had a pre-existing website (, a domain he he intended to phase out) we setup the DNS so three different domain names would all point to "". This meant that the logs would show different domains (yeah, set root, I know).

By adding a bit of regular expression love in the HostAliases setting we were able to handle this easily.

Next, DefaultFile might have been static or dynamic, so we set it to handle HTML and PHP extensions.

Next, and perhaps most important, add some regular expressions to the SkipFiles to ignore sertain directories and files, including the RSS feeds.

That’s it… oh, the GeoIP plugin is amazingly cool, and if it’s installed on your server go ahead and turn it on, nice to see what countries folks are from. Oh, and I like to see more than the default "10" keywords on the front page of the stats. Twenty-five makes me happier.

Here’s the snippet:

  1. SiteDomain=""
  3. HostAliases="localhost REGEX[godblessamericana\.com$] REGEX[charlesphoenix\.com$] REGEX[americanathebeautiful\.com$]"
  5. DirData="G:\myawstats\mydata"
  7. DefaultFile="index.php index.htm index.html"
  9. SkipFiles="robots.txt$ favicon.ico$ wp-login.php$ REGEX[^\/wp-admin] REGEX[^\/dh_phpmyadmin] REGEX[^\/statistics] REGEX[^\/login] REGEX[^\/lists] REGEX[^\/feed]"
  11. MaxNbOfRefererShown = 25
  12. MaxNbOfKeyphrasesShown = 25
  13. MaxNbOfKeywordsShown = 25
  15. LoadPlugin="geoipfree"

top of page

Friendly Results Page File Names (faking index.htm)

Is there a way to make the file names index.html, instead of

Yes! Assuming you have mod-rewrite installed just create an .htaccess in the folder where you have stats files being output. Then add this line:


top of page

More Resources & Help with AWStats