Installing Jawstats for a Webhost


JAWStats is a free, open-source website statistics and analytics package. It runs in conjunction with AWStats and produces clear and informative charts, graphs and tables about your website visitors.

Jawstats presents a user friendly interface that is easily naviagable for end users. Below is a sample screen shot of the stats for this site:


Installation on FreeBSD is somewhat interesting. Instead of using the port, I ended up downloading the source code and installing it by hand which proved much easier as the instructions fit this setup much better. To begin, you need a working copy of awstats installed:

cd /usr/ports/www/awstats
sudo make install clean

That will install a working copy of awstats. You still need to configure it before it will do anything. You need to create a configuration file in /usr/local/etc/awstats/ for each website you have. You can use the configuration program (run as root) to setup each as such:

sudo /usr/local/www/awstats/tools/

After that, it is actually quicker and easier to copy the files and edit them by hand using your favorite editor but whichever you choose, you should end up with a pile of configs.

Now you need to setup awstats to run periodically to parse your weblogs. I run this hourly and have created a perl script to handle this task for me:

#! /usr/local/bin/perl

chdir "/usr/local/etc/awstats/";
my @files = <*>;
foreach $file (@files) {
        $file=~ s/\.conf$//g;
        $file=~ s/^awstats\.//g;
        system "/usr/bin/nice /usr/local/www/awstats/wwwroot/cgi-bin/ -config=$file";
        sleep 1;

This simple program simply iterates through the files and is much simpler than adding a line for each domain to your crontab. I found it difficult to space them and remember each spot I had to add a new domain whenever I set one up. I added the following line to my crontab file:

5       *       *       *       *       root    /home/rnejdl/Scripts/

At this point, you are ready to download and setup jawstats. You can download the latest version at Download that to your home directory and uncompress it as such:

 tethys:/home/rnejdl>mkdir jawstats
 tethys:/home/rnejdl>cd jawstats/
--2009-09-21 22:56:13--
Connecting to||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 256622 (251K) [application/x-tar]
Saving to: `jawstats-0.7beta.tar.gz'

100%[======================================>] 256,622      622K/s   in 0.4s

2009-09-21 22:56:13 (622 KB/s) - `jawstats-0.7beta.tar.gz' saved [256622/256622]

 tethys:/home/rnejdl/jawstats>tar -xvzf jawstats-0.7beta.tar.gz 
x clsAWStats.php                                                
x config.dist.php                                               
x index.php                                                     
x js/                                                           
x js/constants.js                                               
x js/jawstats.js                                                
x js/jquery.js                                                  
x js/jquery.tablesorter.js                                      


x themes/default/style.js
x xml_history.php
x xml_pages.php
x xml_stats.php
x xml_update.php
 tethys:/home/rnejdl/jawstats>rm -Rf jawstats-0.7beta.tar.gz

Now, move the jawstats directory over to /usr/local/www. You now need to configre jawstats to pick up your awstats configuration. Copy the config.dist.php file to config.php and edit it. It should look something like the following:


  // core config parameters
  $sConfigDefaultView    = "thismonth.all";
  $bConfigChangeSites    = false;
  $bConfigUpdateSites    = true;
  $sUpdateSiteFilename   = "xml_update.php";

  // individual site configuration
  $aConfig[""] = array(
    "statspath"   => "/var/lib/awstats/",
    "updatepath"  => "/usr/local/www/awstats/wwwroot/cgi-bin/",
    "siteurl"     => "",
    "theme"       => "default",
    "fadespeed"   => 250,
    "password"    => "letm31n",
    "includes"    => ""


You need to add those 9 lines for each domain you want jawstats to work for. Once you have that, you only need to update your apache configuration. I added the following lines to my http.conf:

    # Directives to allow use of AWStats as a CGI
    Alias /awstatsclasses "/usr/local/www/awstats/wwwroot/classes/"
    Alias /awstatscss "/usr/local/www/awstats/wwwroot/css/"
    Alias /awstatsicons "/usr/local/www/awstats/wwwroot/icon/"
    ScriptAlias /awstats "/usr/local/www/awstats/wwwroot/cgi-bin"
    Alias /jawstats "/usr/local/www/jawstats/"
    Alias /weblogs "/usr/local/www/jawstats/"

    Options None
    AllowOverride None
    Order allow,deny
    Allow from all

Options None
AllowOverride All
Order allow,deny
Allow from all

I also added to the DirectoryIndex definition:

   DirectoryIndex index.php index.cgi index.htm index.html index.html.var index.

In order for a bit of magic to happen where the right stats shows up, I had to modify clsAWStats.php and add a line at line 319:

$sConfig = $_SERVER['SERVER_NAME'];

That tells Jawstats to pull the config for whatever hostname you are calling such that shows stats for instead of the first item in your config file.

Restart apache and you should now be able to go to any of your websites /weblogs/ and see jawstats for that individual domain show up.