edoceo

Installing and Using AWStats

AWStats is an execellent tool for processing server-side web-traffic logs. Internally we use this tool for processing logs from both Apache and Lighttpd.

Configure AWStats

This first example will run a server-wide stats analysis, all sites, all pages.

DirData="/var/cache/awstats"
CreateDirDataIfNotExists=0
DirCgi="/cgi-bin"
DirIcons="http://cdn.edoceo.com/img/awstats"
LogFormat="%virtualname %host %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"

Web Server Log Configs for AWStats

In our environment all hosts log to the same files on our Apache, Lighttpd or Nginx servers, we use a common vhost pattern. We collect the following fields:

AWStatsApacheLighttpdNginx
%virtualname%V%V$server_name
%host%h%h$remote_addr
%logname%u%u$remote_user
%time4%{%s}t%{%s}t$time_iso8601
%methodurl%r%r$request
%code%>s%>s$status

Apache + AWStats Config

LogFormat "%V %h %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost
LogFormat "%V %h %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost
CustomLog /var/log/apache2/access.log vhost
LogLevel warn
ErrorLog "/var/log/apache2/error.log"

See mod_log_config for more information.

Lighttpd + AWStats Config

accesslog.format   = "%V %h %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
accesslog.filename = var.logdir + "/access.log"
server.errorlog    = var.logdir + "/error.log"

See Also: lighttpd loggging configuration

Nginx + AWStats §

http {
    log_format vhost '$server_name $remote_addr - $time_iso8601 "$request" $status $bytes_sent "$http_referer" "$http_user_agent"';
    access_log /var/log/nginx/access_log vhost;
}

Execute First AWStats

Now that AWStats is configured, execute the first pass to update it's data file.

~ # awstats.pl -config=domain.tld -update

Execute to Build Reports

Now we can build the reports.

~ # awstats.pl -config=domain.tld -output > index.html
~ # cd /var/www/site
. # mkdir /var/www/site/stats
. # awstats.pl -config=praxis.edoceo.com
. # awstats.pl -config=praxis.edoceo.com -output > index.html
~ # awstats_buildstaticpages.pl \
    -config=praxis.edoceo.com \
    -update \
    -staticlinks \
    -dir=/var/www/localhost/stats

See Also

Loading Comments from Disqus...