AWStats Installation

From DreamHost
Jump to: navigation, search
DreamHost does not directly support any of the features described on this page and is not responsible for keeping this content updated or accurate. Use at your own risk!
There may be additional information on the talk page.
The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes performed by DreamHost may break your modifications. You, as the user, are responsible for troubleshooting and resolving issues with your customizations.

AWStats is an alternative Web log analyzer that offers a wider range of statistics than Analog.

This guide assumes that your username is yourusername and your domain is You should change it to fit your username and domain.

The instructions provided in this article or section require shell access unless otherwise stated.

You can use the PuTTY client on Windows, or SSH on UNIX and UNIX-like systems such as Linux or Mac OS X.
Your account must be configured for shell access in the Control Panel.
More information may be available on the article's talk page.


Get into the correct directory - in this example it assumes you're installing the awstats in your local directory so go to your local home root:

cd ~/

Download AWStats, get latest from [1].


Extract the TAR

tar xfzv awstats-6.95.tar.gz

Rename the awstats folder and then go to the awstats folder.

mv awstats-6.95 awstats
cd awstats

You should now have a directory:



Static Pages

Changing the Directory Structure

Create a directory named 'data' and change the permissions.

cd ~/awstats
mkdir data
chmod 755 data

Move the files in the /home/yourusername/awstats/wwwroot/cgi-bin/ directory into /home/yourusername/awstats/.

mv ~/awstats/wwwroot/cgi-bin ~/awstats

Setting up the Domain Name

Create a directory in your domain folder (substitute your domain for "").

mkdir ~/

Copy the following:

  • icon
  • css
  • js

To the statistics folder in your domain folder. (substitute your domain for "")

cp -r ~/awstats/wwwroot/{icon,css,js} ~/

It should be noted that you should not call the directory 'stats'. DH uses '' as a default for their Analog statistics.


In the awstats/cgi-bin/ folder, copy awstats.model.conf to, where "" is actually your website domain.

cp ~/awstats/cgi-bin/awstats.model.conf ~/awstats/cgi-bin/

You may need to make the file writable before editing.

chmod 644 ~/awstats/cgi-bin/

Open the file for editing

vi ~/awstats/cgi-bin/

Change the following parameters in the file

  1. Set the changes to the following changing the yourusername and to your information.
  2. Save or upload the file if you didn't use 'vi'.
#Dreamhost rotates the logs and the below makes sure that you get the previous logs too. 
LogFile="/home/yourusername/awstats/tools/  /home/yourusername/logs/*|"
LogFormat="%host %other %other %time1 %methodurl %code %bytesd %refererquot %uaquot"
DefaultFile="index.php index.html"

If you did use 'vi', hit Esc, type :x, and hit Enter. This will save your changes and exit you out of the editor.

Checking AWStats

Verify that all of your *.pl files are with 755 permissions. The first column of output should read: -rwxr-xr-x.

ls -o

If some don't look like that, then you can run this:

find . -name '*.pl' | xargs chmod 755

Then run

ls -o

again to see that they're all correct now.

Check that everything is working

perl /home/yourusername/awstats/tools/ -update \
-awstatsprog=/home/yourusername/awstats/cgi-bin/ -dir=/home/yourusername/
The above has been entered as two lines. If entered in one line, remove the backslash (\)

Check the output folder (/statistics/) in your browser. Look at the file. Does everything look good? Great! Then let's setup a cron job to do this automatically.

NOTE: If you have a Ruby on Rails site, you will not be able to see this output with your browser. One way to get around this problem is to change the last part of the command to this:


CRON Script

The Crontab page will be of some use if you are having trouble. For example, you have to fill out the MAILTO="" field in order for Dreamhost to use your crontab.

Edit the crontab

crontab -e

Insert the following

If the line is too large in the default editor than it will fall to the next line, you will have to manually go back and press delete to make sure it is all on the same line. It all must be on the same line.
As always, change the yourusername and to your information.
The following has been moved to three lines to save from side scrolling, it still needs to be one line.
0 3 * * * /usr/bin/perl /home/yourusername/awstats/tools/ -update -awstatsprog=/home/yourusername/awstats/cgi-bin/
-dir=/home/yourusername/ >/dev/null 2>&1

The >/dev/null 2>&1 is to prevent the job from mailing you the results every time the script runs. The mail ends up in /home/username/MailDir

Replace with >/dev/null to just receive errors

Save and close

CTRL + O To Save
Press Enter To Overwrite the File
CTRL + X To Quit
  • Note about crontab: you must specify a full path to perl or the script will not work.

.htaccess file

Edit the .htaccess file in the output directory ( and type the following.


That will show the stats overview as the default index when you open "". You might also want to password protect it.


If for some reason .htaccess files do not work, creating a symbolic link can achieve the same result

ln -s ~/ ~/

AWStats For Another Domain

  1. Repeat the 'Configure' step for the domain name.
  2. Repeat the 'Setting up the Domain Name' step and copy the folders to the domain name.
  3. Repeat 'Crontab' step by adding a new line and changing the details for the other domain name.
    • Change the new crontab time by changing the first number to increments of 15 or whatever number besides that of the last one and the second number to the same unless you would have two running at the same time.
  4. Repeat the '.htaccess file' step for the new domain.
  5. And run this to create the stats for the first time.
perl /home/yourusername/awstats/tools/ \
-update -awstatsprog=/home/yourusername/awstats/cgi-bin/ \

Dynamic pages

  • There's an dynamic setup available here: AWStats_Installation_(alternative). It allows the data to be dynamically updated through the browser (real-time data update), and access to previous months (or yearly) data.


Remove 'Useless' Files

Go to the awstats folder (if you renamed the directory then go to that)

cd awstats

Remove all the files except for the wwwroot folder

rm -rf docs

Then move the contents of wwwroot to the current directory

mv wwwroot/* .


Change to the cgi-bin folder

cd cgi-bin

Here there is an example configuration.

  1. Want to copy and edit this.
  2. Do this for as many domains as you have.
cp awstats.model.conf
cp awstats.model.conf
cp awstats.model.conf

Now, editing the config. Things should be set as follows: (You can skip this bit and use the Config Generator)

HostAliases="localhost REGEX[YourDomain\.TLD$]"

That should do it, to test it out open


Update the Stats

You can update the stats from your browser.

If you want to use crontab

crontab -e

Then type on a line, which will update the stats every hour.

0 * * * * /home/YourUserName/YourDomain/AwStatsDir/cgi-bin/ -config=mysite -update >/dev/null

Changing the Permissions

If you changed the awstats folder, just replace the awstats-6.5 to that of your awstats folder.

chmod -R 755 awstats-6.5

This will fix the 500 Internal Server Error and Premature end of script headers in your server error log.

Installing JAWStats for use with AWStats

Note: JAWStats hasn't been actively developed for a year, you might want to look at the MAWStats fork:

JAWStats is not an AWStats replacement. Instead it runs in conjunction with AWStats and produces attractive, clear and informative charts, graphs and tables about your website visitors.

Jawstats 400px.jpg

The steps required to install JAWStats begin with the installation of AWStats as outlined above (which a few very minor changes).

Once you've completed and confirmed your AWStats is working this section should help you get JAWStats up and running successfully.

Getting JAWStats

For this you'll want to go to the JAWStats download page located a

Alternatively, you can download the current version (at the time of writing) from the command line:


If you've downloaded it using the command line before you untar it you'll want to have it inside the directory (because it'll untar without it's own container file).

So for example:

mkdir ~/jawstats/
mv ~/jawstats-0.7beta.tar.gz ~/jawstats/
cd ~/jawstats/
tar xfzv jawstats-0.7beta.tar.gz
rm -f .jawstats-0.7beta.tar.gz (just cleaning up the archive)

You should now have a directory:


Who's contents should look like this:


These are the main application files for JAWStats.


The installation of JAWStats is very simple. If you've followed the instructions for the AWStats installation above and have it working then we will only make a few simple changes and you'll be up and running!

Moving the files into place

In the section Setting up the Domain Name above we copied some AWStats files into the folder we'd using to view/access AWStats, as shown below:

cp -r ~/awstats/wwwroot/{icon,css,js} ~/

For JAWStats we won't actually need those. Instead we'll be using the JAWStats files you just downloaded and extracted.

So lets clear out the AWStats files in our domain folder and copy our new JAWStats files into place:

rm -fr ~/*
cp -R ~/jawstats/* ~/

JAWStats configuration

Now that all the files are in place we've got to do a quick bit of configuring to let JAWStats know where to find AWStats and the files it will need to display your data.

First, lets move into the directory.

cd ~/

You'll see a few files in here, but you can ignore everything but a file called config.dist.php.

This is the file that will become your configuration, lets rename it:

cp ./config.dist.php ./config.php

and open the file for editing

vi config.php

What you see might look confusing, but we only need to worry about the site configuration section(s) which look like this:

 // individual site configuration
 $aConfig["site1"] = array(
   "statspath"   => "/path/to/data/",
   "updatepath"  => "/path/to/",
   "siteurl"     => "",
   "theme"       => "default",
   "fadespeed"   => 250,
   "password"    => "my-1st-password",
   "includes"    => ""

The line we'll be editing are:

$aConfig["site1"] = array(
"statspath"   => "/path/to/data/",
"updatepath"  => "/path/to/",
"siteurl"     => "",
"password"    => "my-1st-password",

And the changes are actually pretty straight froward. Using the AWStats configuration as an example we'll end up with something like this:

 // individual site configuration
 $aConfig[""] = array(
   "statspath"   => "/home/yourusername/awstats/data/",
   "updatepath"  => "/home/yourusername/awstats/cgi-bin/",
   "siteurl"     => "",
   "theme"       => "default",
   "fadespeed"   => 250,
   "password"    => "mynewsupersecretpassword",
   "includes"    => ""
 ); is the website domain name you used in naming your file.

statspath is the DirData setting you added to the file

updatepath is the location of the cgi-bin which you moved in the Changing the Directory Structure section.

siteurl is simply the domain name which JAWStats will display in heading making it easy to know what it is you're looking at.

password is pretty self explanatory but it's a good idea to change this and if you leave $bConfigUpdateSites option in the section above in it's default state (true) you'll be asked to input the password you configure here to run an update on the sites stats (an handy feature for the stats obsessed!).

Wrap-up and CRON Script changes

That covers basic configuration. You'll notice the JAWStats file has (by default) 2 example site sections. You can add additional sites to the configuration as above, as long as each site has a matching (and working!) AWStats configuration you can quickly and easily switch between viewing statistics for each domain from the JAWStats interface.

Testing and CRON setup with JAWStats is pretty much the same. But you'll want to change the line you'll be using for you CRON script.

The AWStats example looked like this:

0 3 * * * /usr/bin/perl /home/yourusername/awstats/tools/ -update -awstatsprog=/home/yourusername/awstats/cgi-bin/
-dir=/home/yourusername/ >/dev/null 2>&1

However JAWStats doesn't need AWStats to do as much work, we only need to generate the data files. So instead you can use something like this:

0 * * * * perl /home/yourusername/awstats/tools/ now 
-configdir=/home/yourusername/awstats/cgi-bin/ -awstatsprog=/home/yourusername/awstats/cgi-bin/

Notice we've skipped the because we'll be using JAWStats to provide much nicer looking pages. I also use the which is under the AWStats tools directory. This script is will process all the files in your -configdir automatically (excluding the awstats.model.conf file). So if you have more then a single domain setup you can use a single CRON script and process them all rather then installing one AWStats CRON job for every domain.

If everything goes right you should now have an attractive and easy to use interface setup to use your AWStats datafiles. Enjoy!

Importing your old log files

To run AWStats on all of your old logs, you can create a shell script (found at

Make sure your AWStats data directory is empty before you run the script.

In a text editor (like vi or pico), create a shell script.

pico parse_old_stats

Enter the following

for log in $(ls -rt ~/logs/*.gz)
   echo $log
   echo “zcat”
   zcat $log > ~/tmp/access_log
   sleep 5
   echo “”
   ./awstats/cgi-bin/ -update -LogFile=/home/yourusername/tmp/access_log
   sleep 5

Make sure the script can run

chmod 755 parse_old_stats

The sleep commands give AWStats enough time to process between log files.

Alternative old log files import

You can also use the Logresolvemerge tool provided with AWStats (in tools directory) replacing:

LogFile="/home/yourusername/awstats/tools/ /home/yourusername/logs/*.* |"

in the configuration file for the first run. See the Awstats FAQs: and for details.


  • You can make any other changes you deem useful to the config file, it's decently commented. Also, if your log files are very large (you get lots of hits), you'll probably have to run awstats once daily to put less strain on the server. There are some guidelines for that on the AwStats website. You'd have to change the logfile location in that case too, to use the current log.

External Links

  • Notes by Skybly - in the DreamHost forums on installation info.
  • AWStats Hack - Discussion regarding a hack of awstats that over-writes your index.php files. Only for dynamic installations and in versions previous than 6.4.
  • AWStats Configuration - List of configuration directives with instructions. Easier on the eyes than what's in the config files.