Articles February 16, 2006 at 2:58 pm

*WIP* Running AWStats on Mac OS X Server (revised)

Mac OS X Server has tools to monitor trends in network traffic and look at your log files, but I’ve always wanted easy to read, detailed stats for my web server.

AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It’s open source and not too difficult to set up.

(This has been tested on OS X Server 10.3.9 and 10.4.4)

1. Go to: and download the latest, greatest version (as of now, awstats-6.5).

2. un-tar it.

3. move everything to:


4. copy the contents of awstats/wwwroot/cgi-bin/ to /Library/WebServer/CGI-Executables/

This includes:

5. copy the rest of the contents of awstats/wwwroot/ into:

This includes:


6. Edit:



my $DIRCONFIG = “/etc/awstats”;

change to:

my $DIRCONFIG = “/library/webserver/CGI-Executables”;


my $Awstats=’’;

change to:

my $Awstats=’/library/webserver/CGI-Executables/’;


7. run the script to do several setup actions:

cd /Library/WebServer/awstats/
sudo perl /Library/WebServer/awstats/tools/

at the prompt:

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ?

..hit ‘y’ and ‘enter’.

at the prompt:

-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: demo
Your web site, virtual server or profile name:

..enter your site name:

..then hit ‘enter’ two more times when prompted.

8. edit the config file it created at:




change to:

(..or whatever the virtual host’s log file name is. Check Server Admin if you’re unsure.)



Possible values: 1,2,3,4 or “your_own_personalized_log_format”
# 1 – Apache or Lotus Notes/Domino native combined log format (NCSA combined/XLF/ELF log format)
# 2 – IIS or ISA format (IIS W3C log format). See FAQ-COM115 For ISA.
# 3 – Webstar native log format.
# 4 – Apache or Squid native common log format (NCSA common/CLF log format)
# With LogFormat=4, some features (browsers, os, keywords…) can’t work.

I believe OS X Server’s default is “common” – so for the first run, you may have to set LogFormat=4. More on that below. **



..and add any aliases or ip addresses for this site.



change to:


(The comment suggests that this is supposed to be the default.. but it doesn’t seem to be.
“.” means the same directory as in our case: /Library/WebServer/CGI-Executables/)


change to:


change to:


AWStats can purge log file, after analyzing it. Note that AWStats is able
to detect new lines in a log file, to process only them, so you can launch
AWStats as often as you want, even with this parameter to 0.


change to:


change to:
DefaultFile=”index.php index.html”
(or whatever your default file type is)

NotPageList=”css js class gif jpg jpeg png bmp ico swf”

add any other file types you don’t want to count toward “page hits”:
NotPageList=”inc css js class gif jpg jpeg png bmp ico swf”


Change this to “0” if you want the week report to start on sunday instead of the default monday.

Make any other edits you’d like and save the config file.

9. Move this file to your /library/webserver/CGI-Executables/ directory:

sudo mv /library/WebServer/awstats/wwwroot/cgi-bin/ /library/webserver/CGI-Executables/

10. Either copy the /icon directory into your website’s root directory or create a symlink to a common /icon directory shared by all of your virtual hosts:
ln -s ../icon icon

11. run it:
sudo perl /Library/WebServer/awstats/tools/ now

Your stats should now be available at:

12. For ease of use, I set up a redirect page at:
..that sends you to:

Repeat steps 7-12 for each additional virtual host.

Automate the update with a cron job.

I used CronniX to add:
0 * * * * root /Library/WebServer/awstats/tools/ now

This will update the stats for all of the sites you’ve set up this way at the top of the hour, every hour.


OS X Server 10.3.9 and 10.4.4 both seem to use the “common” apache log configuration by default. I’m interested in getting more information than that provides (browsers, os, search keywords, etc), so I switched to the “combined” format:

a. Using Server Admin, click on “web” > “settings” > “Sites”.

b. For each web site defined, click on the domain name, click the “edit” button (pencil icon at the bottom of the screen). Under the “logging” tab: change value for “format” from “common” to “combined”. Click the “back” arrow and do the same for your other sites.

c. Click save.

d. Since we’ve changed the log format, we need to re-edit the awstats config file:


change to:

save the config file.

e. If you didn’t previously set up awstats to purge the log file after it uses it (PurgeLogFile=1), you may want to archive the old log file now and start fresh with a blank one.

The default directories AWStats tried to put things in didn’t always work for me. I had to play around with my setup before I came up with these instructions. This worked for me, running multiple virtual hosts on both OS X Server 10.3.9 and 10.4.4. If you have any corrections or suggestions to add to this, I’d like to hear any feedback.


  • Hey man, great page. Due to my rolling logs, it barfs. I shoved in a wildcard for the awstats vhost pointer:

    Error: Couldn’t open server log file “/var/log/apache2/access_mydomain_log*” : No such file or directory

    I now have 3 logs from restarting apache:


    Any idea how I can get that workin?

    access_mydomain_log.* is my first trick, but the first wildcard would have worked.


  • OK I have it on a launchd hourly update now.

Leave a reply

You must be logged in to post a comment.