AWStats Installation (alternative)

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</tt> Remove all the files and folders except in the 'wwwroot' folder. rm -rf README.TXT</tt> rm -rf docs</tt> rm -rf tools</tt> Move the contents of wwwroot in to the current directory mv wwwroot/* .</tt> Delete the now unneeded wwwroot directory (optional):

rm -rf wwwroot</tt> Change to the cgi-bin directory. cd cgi-bin</tt> Make copies of the model configuration file for each domain you want to report.

cp awstats.model.conf awstats.mydomain.com.conf</tt> cp awstats.model.conf awstats.mydomain2.com.conf</tt> cp awstats.model.conf awstats.mydomain3.com.conf</tt> 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"</tt> SiteDomain="mydomain.com"</tt> HostAliases="REGEX[mydomain\.com$]"</tt> DirData="/home/yourusername/mydomain.com/awstats"</tt> DirIcons="/awstats/icon"</tt> AllowToUpdateStatsFromBrowser=1</tt> 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 <tt>crontab -e</tt> to open, <tt>crontab -l</tt> to list the file). (Replace <tt>awstats</tt> with the full path to your AWStats installation, e.g. <tt>/home/yourusername/mydomain.com/awstats/</tt>.) <tt>0 * * * * /usr/bin/perl awstats/cgi-bin/awstats.pl -config=mydomain.com -update >/dev/null </tt>

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

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

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

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): <tt>chmod -R 755 aw</tt>

Related Links
AWStats - Main page

AWStats_Installation - Main installation page