How to enable GeoIP in Awstats using Cpan

By | February 2, 2010

It is very useful to see visitors’ country information when you’re watching awstats logs. Let me tell you what to do if you don’t have Geoip support enabled on your server.

First of all, we will need to download and install GeoIP. We will take free version, but if you really require good stats, you may buy one. Let’s switch to a temporary directory to issue the following commands:

wget http://maxmind.com/download/geoip/api/c/GeoIP.tar.gz;
tar xzvf GeoIP.tar.gz;
cd GeoIP-1.4.6;
./configure;
make;
make install;

You might need to replace 1.4.6 with your version of Geoip, as 1.4.6 is the latest one for today.

Then we need to install Geoip using cpan. I suppose, that you are already familiar with cpan, that’s why I won’t describe initial span setup procedure here. In order to install it, we need to enter cpan from command line. Then issue the following command:

install Geo::IP

Then type quit. And the final stage: we will add Geoip support to awstats.conf. You’re welcome to do it with any editor you like, here is a command line variant using sed.

sed -i ‘s/#LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat”/LoadPlugin=”geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat”/’ /etc/awstats/*.conf

You’re done now. Have fun with your updated awstats!