AWStats

From apnsGuide

Jump to: navigation, search

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.

  1. Connect to the server via SSH-2 and change to /usr/local/:
    • cd /usr/local/
  2. Download AWStats from SourceForge using wget, decompress, and change to the directory
  3. Make a directory to store the AWStats configuration
    • mkdir /usr/local/etc/awstats/
  4. Edit AWStats with your favorite text editor, (e.g. vi, nano, ed) to reflect your logfile settings:
    • vi wwwroot/cgi-bin/awstats.model.conf
  5. Change the following lines:
    • LogFile="/var/log/httpd/mylog.log" to LogFile="/var/log/httpd/access_log"
    • DirData="." to DirData="/usr/local/awstats-6.5/wwwroot/"
    • SiteDomain="" to SiteDomain="*domain*"
    • DirIcons="/icon" to DirIcons="icon"
  6. Save changes to /usr/local/etc/awstats/awstats.*domain*.conf, exit
    • (under vi): ESC + :wq /usr/local/etc/awstats/
  7. 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/
  8. 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
  9. 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
  10. Fix permissions so that the Web server can open up pages under the AWStats install directory
    • chmod 701 /usr/local/awstats-6.5/
  11. 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.

Image:AWStats-cronjob.png

See Also

AWStats Documentation

Personal tools