awstats and lighttpd

Today I decide to make an access analysis of my web sites, and looks awstats is the most popular open source one.

Installing it is a piece of cake thanks to the FreeBSD ports system. However the documents only specified how to set it up with Apache and analysis Apache logs. Fortunately the lighttpd log file format is CLF like by default, which is compitable with teh Apache “combined” format. This saved me a lot of time.

On FreeBSD awstats is installed at /usr/local/www/awstats by default. To provide web access to the reports, I setup a virtual host for it. This way my access to the reports won’t polute the access log. (Hmmm, how many times will I access the reports a day?)

$HTTP["host"] == "my.awstats.domain.name" {
server.document-root        = "/usr/local/www/awstats/"
accesslog.filename          = "/var/log/awstats.dryice.access.log"
cgi.assign     = ( ".pl" => "/usr/local/bin/perl" )
alias.url      = (
"/awstatscss/" => "/usr/local/www/aswtats/css/",
"/awstatsclasses/" => "/usr/local/www/aswtats/classes/",)
}

There should be another alias of /awstatsicons. However I find I can change it in awstats config file with knob DirIcons, so I decided to save some work from lighttpd.

Also I don’t like my statics to be public readable, so I use the auth module to protect it.

I have several sites running and the “include” feature of awstats comes handy. I copied the default config file awstats.model.conf to awstats.common.conf, and made common changes in it. And In my site config files like awstats.dryice.name.conf, I use

Include "awstats.common.conf"

I use the FreeBSD newsyslog utility to rotate my log files, So I have

LogFile="bunzip2 -c /var/log/archives/dryice.access.log.0.bz2 |"

in my config file. The -c says unzip to standard output so I can pipe it. Then I only have a few knobs in the site config file, like SiteDomain and HostAliases.

After running the update as in the awstats documents, I have a report ready for me :)

Awstats comes with several plugins. And I found GeoIP and xwhois fit me most. They are all in the FreeBSD ports tree so there’s nothing to say about install. The GeoIP free database could be download here and the city database here.

OK, all settled. The only thing left is to schedule several crontabs to run the update automically.

It is said the free GeoIP database is updated monthly, but looks they are doing a better job. So I have a script

#/bin/sh

cd /usr/local/www/awstats/cgi-bin

wget http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz
gunzip -f GeoIP.dat.gz

wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip -f GeoLiteCity.dat.gz

and have it run every Wednesday.

For Chinese users, awstats doesn’t come with many Chinese search engines. Chedong provided a patch version that contain those search engines like sohu.com or qq.com. It is a patch against previous awstats, but we can easily find what he added and do it ourself.

Tags: , ,

Post a Comment

You could use <code type="name"> to get your code colorized

Your email is never published nor shared. Required fields are marked *

Close
E-mail It