AWstats

We are going to use AWstats for gathering and displaying request statisticts from the Apache<. SAWstats<, an improved version of AWstats, can be used to analyze Nginx< and Squid< access logs.

This installation guide for CentOS 5 is based on AWstats documentation< and guide from lissyara<.

AWstats installation

Start from installing the attached awstats tarball or awstats-xxx.noarch.rpm<.

mkdir /etc/awstats
cp /usr/etc/awstats/awstats.model.conf /etc/awstats/awstats.conf<

Edit awstats.conf:

LogFile="/var/log/httpd/access_log"
SiteDomain="ourdom.com"
HostAliases="ourdom.com REGEX[.*\.ourdom\.com] 127.0.0.1 localhost"
DirData="/var/lib/awstats"
DirCgi="/awstats"
DirIcons="/awstatsicons"
LoadPlugin="tooltips"
LoadPlugin="decodeutfkeys"
LoadPlugin="hashfiles"
LoadPlugin="rawlog"<

Note about log formats:

 [1]
%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"
"%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"
(host user date method url code size referer ua)
[2]
date time c-ip cs-username cs-method cs-uri-stem sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)
(date host user method url code size ua referer)
[3]
date method code host ua referer url size
(-"-)
[4]
%h %l %u %t \"%r\" %>s %b
(host user date method url code size) 
<

Format for Apache with virtual host name at the end:

 %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %virtualname<

Format for Nginx with virtual host name at the end:

 %host %other %logname %time1 %method %url %other %codequot %bytesd %refererquot %uaquot %otherquot %virtualname <

Verify that standard perl modules exist

perl -MURI::Escape -e1
perl -MStorable -e1<

Create work directory

mkdir /var/lib/awstats<

Enable hostinfo - install perl whois module

cpan Net::XWhois<

and add the following in awstats.conf

LoadPlugin="hostinfo"<

Create cron job in /etc/cron.hourly/awstats

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=ourdom.com<

Augment Apache configuration

#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory><

Install GeoIP C API

yum install GeoIP GeoIP-data GeoIP-devel<

Install GeoIP perl module (the devel package is required for build)

cpan Geo::IP<

Create directory for GeoIP data

mkdir -p /var/www/geoip/data<

Download geolite country< and geolite city< binary files GeoIP.dat.gz< and GeoLiteCity.dat.gz< from free maxmind database< or full latest version<.

Move downloaded files to /var/www/geoip/data. Enable GeoIP in /etc/awstats.conf

LoadPlugin="geoip GEOIP_STANDARD /var/www/geoip/data/GeoIP.dat
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /var/www/geoip/data/GeoIPCity.dat"<

Recreate statistics

rm /var/lib/awstats/*
sh /etc/cron.hourly/awstats<

Restart apache and surf to this url

http://ourdom.com/awstats/awstats.pl<

JAWstats

JAWstats< is addon to AWstats on javascript steroids (see demo<). Download the latest version< (I checked out the latest version from SVN< because I needed "statsname" setting) and unpack into /var/www/admin/jawstats. Copy config.dist.php into config.php and adjust a few parameters:

$aConfig["ourdom.com"] = array(
  "statspath"   => "/var/lib/awstats/",
  "statsname"   => "awstats[MM][YYYY].txt",
  "updatepath"  => "/awstats/awstats.pl/",
  "siteurl"     => "http://www.ourdom.com",
  "sitename"    => "Our Dom Ltd",
  "theme"       => "default",
  "fadespeed"   => 250,
  "password"    => "my-1st-password",
  "includes"    => "",
  "language"    => "en-gb"
);<

Attachments