AWStats Installation (alternative)

From DreamHost
Jump to: navigation, search

This alternative installation, configures Awstats to be dynamically updated, executed as a cgi script. This allows Awstats to show frames in the web stat pages, but most important, it allows the viewing of previous months' data, as well as real-time statistics update through the browser.

This is a much more flexible alternative, but it is also much more demanding on the server. Read the main AWStats_Installation page for detailed instructions for some of these steps.


  • This guide assumes that your username is yourusername and your domain is mydomain.com. You should change it to fit your username and domain. It also assumes awstats as the folder you what to install (DH uses 'mydomain.com/stats' as a default for their Analog statistics.)

Change to your domain directory:

cd mydomain.com

Download the latest version of AWStats here

wget http://awstats.sourceforge.net/files/awstats-7.0.tar.gz

Extract the files

tar xfzv awstats-7.0.tar.gz

Delete the tar file (optional):

rm -rf awstats-7.0.tar.gz

Rename the newly created folder to whatever you like

mv awstats-7.0 awstats

Change to the newly renamed folder

cd awstats

Remove all the files and folders except in the 'wwwroot' folder.

rm -rf README.TXT
rm -rf docs
rm -rf tools

Move the contents of wwwroot in to the current directory

mv wwwroot/* .

Delete the now unneeded wwwroot directory (optional):

rm -rf wwwroot

Change to the cgi-bin directory.

cd cgi-bin

Make copies of the model configuration file for each domain you want to report.

cp awstats.model.conf awstats.mydomain.com.conf
cp awstats.model.conf awstats.mydomain2.com.conf
cp awstats.model.conf awstats.mydomain3.com.conf

Edit the config file lines shown below, as shown. You can edit the config file by downloading it, using a text editor on your PC and uploading it back to the cgi-bin directory, or by using vi, pico or another text editor.

LogFile="/home/yourusername/logs/mydomain.com/http/access.log"
SiteDomain="mydomain.com"
HostAliases="REGEX[mydomain\.com$]"
DirData="/home/yourusername/mydomain.com/awstats"
DirIcons="/awstats/icon"
AllowToUpdateStatsFromBrowser=1

That should do it. To test it out, open:

http://mydomain.com/awstats/cgi-bin/awstats.pl?config=mydomain.com

You can update the stats from your browser. If you want to use crontab, insert this line in your crontab (type crontab -e to open, crontab -l to list the file). (Replace awstats with the full path to your AWStats installation, e.g. /home/yourusername/mydomain.com/awstats/.)

0 * * * * /usr/bin/perl awstats/cgi-bin/awstats.pl -config=mydomain.com -update >/dev/null 

This will update the stats every hour. Note that crontab needs a full path to perl. To double-check your path, type which perl at the command line.

Create an entry for each domain you have configured ... or use the awstats_updateall.pl file in the Tools directory. Run awstats/tools/awstats_updateall.pl --help to review the options. Here's an example:

0 * * * * /usr/bin/perl awstats/tools/awstats_updateall.pl now -configdir=awstats/cgi-bin -awstatsprog=awstats/cgi-bin/awstats.pl >/dev/null 

500 Internal Server Error

If you are getting the "500 Internal Server Error" in your browser and/or "Premature end of script headers" message in your server error log, ensure your scripts are NOT writable by anyone but the owner user. This is because Dreamhost runs suexec, as described in the Knowledge Base. Try doing the following (where aw is the awstats folder):

chmod -R 755 aw

Related Links

AWStats - Main page
AWStats_Installation - Main installation page

Personal tools