AWStats
From apnsGuide
Contents |
Introduction
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 uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.
Installing
You will need shell access in order to follow along with the example.
- Connect to the server via SSH-2 and change to /usr/local/:
cd /usr/local/
- Download AWStats from SourceForge using wget, decompress, and change to the directory
wget http://superb.dl.sourceforge.net/sourceforge/awstats/awstats-6.5.tar.gz && tar -xvzf awstats-6.5.tar.gz && cd awstats-6.5
- Make a directory to store the AWStats configuration
mkdir /usr/local/etc/awstats/
- Edit AWStats with your favorite text editor, (e.g. vi, nano, ed) to reflect your logfile settings:
vi wwwroot/cgi-bin/awstats.model.conf
- Change the following lines:
LogFile="/var/log/httpd/mylog.log"toLogFile="/var/log/httpd/access_log"DirData="."toDirData="/usr/local/awstats-6.5/wwwroot/"SiteDomain=""toSiteDomain="*domain*"DirIcons="/icon"toDirIcons="icon"
- Save changes to /usr/local/etc/awstats/awstats.*domain*.conf, exit
- (under vi):
ESC + :wq /usr/local/etc/awstats/
- (under vi):
- Copy the new configuration to /usr/local/etc/awstats/
cp /usr/local/awstats-6.5/wwwroot/cgi-bin/awstats.model.conf /usr/local/etc/awstats/
- Run AWStats to generate the statistics, if you want the main page to bring up stats for the domain, then replace *domain*.html with index.html
/usr/local/awstats-6.5/wwwroot/cgi-bin/awstats.pl -config=*domain* -output > /usr/local/awstats-6.5/wwwroot/*domain*.html
- Make a symbolic link of wwwroot over to somewhere on your Web site for statistics, for example to make http://*domain*/stats/ the AWStats reporting directory,
cd /var/www/html/ && ln -s ../../../usr/local/awstats-6.5/wwwroot/ ./stats
- Fix permissions so that the Web server can open up pages under the AWStats install directory
chmod 701 /usr/local/awstats-6.5/
- Access http://*domain*/stats/*domain*.html
Automating via a Cronjob
If you have shell access you can use apnscp esprit's Cronjob Manager to automatically update statistics every night at 2 AM, for example:
* 2 * * * /usr/local/awstats-6.5/wwwroot/cgi-bin/awstats.pl -config=*domain* -output > /usr/local/awstats-6.5/wwwroot/*domain*.html
will automatically run AWStats nightly at 2 AM EST.

