Easy AWStats Installation Tutorial



I just switched over to Dreamhost from another host and the one thing that took me more work than I wanted was getting AWStats set up properly and efficiently. The tutorial on the Wiki is hard to work with and my method can be completed much more quickly, and with less possibility for losing log entries. This method takes the last three days of log files, temporarily merges them, and then processes for new stat entries based on the three days of entries. No lost entries upon the log rollovers and no lost entries based on log rotation corruption (as long as it doesn’t last longer than three days). Yes, this is long, but I felt it better to be thorough to help novice users as well as be able to help more experienced users.


  1. I have zipped up the necessary files for version 6.5 that you can download here. Unpack the files on your local computer once downloaded keeping the directory structure intact.

(You can also download the most current release or older versions from the AWStats homepage. The version I have zipped up does NOT include the documentation and miscellaneous files with it, so if you need those, grab it from the AWStats site. The rest of this tutorial will be based off my custom version.)


  1. OK first thing, confirm that you have two directories, [color=#00CC00]cgi-bin[/color] and [color=#00CC00]awstats[/color]. If you don’t, start over. Open up the [color=#00CC00]awstats[/color] folder and open up index.php with your preferred text editor. The ONLY thing you need to change is on line 2. Change domain.com to your domain.tld and make sure the quotes and semicolon are still there. Save it and close it. You are all done with the [color=#00CC00]awstats[/color] directory now.

  2. While you are working on the other areas of this installation, you can upload the awstats directory to your /home/username/domain.com directory as it will take a few minutes.

  3. Open up the [color=#00CC00]cgi-bin[/color] folder now. I have included a sub-directory, stats, in here just in case you have other files on the server in your cgi-bin. No need for clutter. Open up the stats folder. You should see four folders, two conf files and two pl files. The ONLY file you will need to edit here is awstats.conf. (The awstats.model.conf file has been included as an original version of the conf file in case you want to reference it to see the changes I have made.)

Configuration File Changes
a. Open up the awstats.conf file and work your way down. The first change you need to make is the LogFile line. Change username to your username, domain.com to your domain.tld (follow the directory structure on your FTP). Then also change the 999999’s to the numbers shown on the FTP inside your logs directory. Here is an example:

You have to keep the perl up front to let the server know that you are processing a perl script first. The -24 and -48 and numbers like that are telling the server to look at today’s log, yesterday’s log, and the log from two day’s ago and then temporarily merge them using logresolvermerge.pl. This method reduces the amount of errors and missed entries.

b. The next change is for the SiteDomain variable. You will change domain.com to yourdomain.tld. Always keep the quotations around variables! SiteDomain="domain.com"c. Do the same for HostAliases right below the SiteDomain area.

d. Change the DirIcons variable now. Are you starting to see why the directory structure using my method is so important? Change domain.com to yourdomain.tld. DirIcons="http://www.domain.com/awstats/icon"That’s about it! Feel free to look through the other variables and change any of those if you need that functionality. A few other changes I already made for you was for AllowFullYearView and DNSLookup.

  1. Now you can upload the [color=#00CC00]cgi-bin[/color] directory to the web server. Make sure you are back at the /home/username/domain.com directory. Upload cgi-bin in it’s entirety. NOTE: if you already have a cgi-bin directory, go into that and upload the stats directory into there.

[color=#CC0000]Server Setup[/color]

  1. You need to CHMOD a few files now. Go to the cgi-bin/stats directory on the server and CHMOD awstats.pl and awredir.pl both to 755. Now go into the tools directory and do the same for logresolvemerge.pl

At this point you should be all set for AWStats to work. Now you will want to set up a cronjob to make this bad boy update hourly and while you are at it, you will probably want to password protect this directory.

[color=#CC0000]Crontab Setup[/color]

I used the DH Crontab Wiki for this portion myself.

  1. How you go about getting this to work is up to you. I used Putty and then followed the steps to manually input the crontab line. In the end I used the following as my crontab line though:

By doing it this way, the script will execute, but also append the results of the execution to either the success log (cronaw.log) or the error log (cronaw.err). These will reside in your [color=#00CC00]awstats[/color] directory. If any problems occur with the line you used for the crontab, they will show up in these files. Make sure you keep all of this on one line and insert a blank line underneath that one.

NOTE: Make sure you have enabled SSH access in the control panel before you try to complete this portion.

[color=#CC0000]Authentication Setup[/color]

  1. You can either create your own .htaccess and .htpasswd files to accomplish this task or just use the control panel to password protect your cgi-bin/stats directory. Pick your poison.

[color=#CC0000]Accessing the Stats[/color]

  1. You have two options here. You can either go to www.domain.com/stats and it will redirect you to the stats page or you can go directly to www.domain.com/cgi-bin/stats/awstats.pl. It’s your call there.

Now you are all done with every portion of AWStats! It will auto update on the hour for you, it is password protected, and you have fought a good battle against missing log entries. If any questions arise, I will do my best to answer them and adjust this tutorial appropriately, if necessary.


If you found this tutorial helpful, please keep me in mind for your next design, search engine optimization, or statistical analysis project. Feel free to request a portfolio for any of those areas.

If you don’t want to do this on your own and want it done for you quickly and professionally, I can be hired for the small amount of $20 to complete the tasks above.

Good luck!