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.

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:


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.

~ # -config=domain.tld -update

Execute to Build Reports

Now we can build the reports.

~ # -config=domain.tld -output > index.html
~ # cd /var/www/site
. # mkdir /var/www/site/stats
. #
. # -output > index.html
~ # \ \
    -update \
    -staticlinks \

See Also