Display Country Stats In Awstats By Using GeoIP

There are two different ways to get country information displayed in AWStats.

Use Reverse DNS Loopkups

The simplest way to display country stats in AWStats is to enable reverse DNS lookups for each IP address, which AWStats can attempt to parse the country info out of.

This method has two problems, the reverse DNS loopkup: 1) will greatly slow down the update process (5x-10x), and 2) is not very accurate (you’ll get allot of “unknowns”).

1. Edit your website’s awstats configuration file (via Notepad):
C:\WampDeveloper\Tools\awstats\wwwroot\cgi-bin\awstats.domain.name.conf

Update –

# Possible values:
# 0 - No DNS Lookup
# 1 - DNS Lookup is fully enabled
# 2 - DNS Lookup is made only from static DNS cache file (if it exists)
# Default: 2
# 
DNSLookup=1

2. Delete old awstats data files:
C:\WampDeveloper\Tools\awstats\wwwroot\data\*

3. And in URL /stats, click on “Update now”.

Use AWStats GeoIP Plugin

To get more accurate and faster country results in AWStats, use its GeoIP plugin…
http://awstats.sourceforge.net/docs/awstats_contrib.html#geoip

1. Install the Perl “Geo::IP::PurePerl” module:

Open command-line and execute –

perl -MCPAN -e shell;
install Geo::IP::PurePerl
exit

2. Download GeoIP database:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

Extract/place GeoIP.dat file into folder –
C:\WampDeveloper\Tools\GeoIP\

3. Update awstats configuration file for website:

Edit your website’s awstats configuration file (via Notepad) –
C:\WampDeveloper\Tools\awstats\wwwroot\cgi-bin\awstats.domain.name.conf

Load plugin GeoIP (uncomment and update line) –

LoadPlugin="geoip GEOIP_STANDARD C:/WampDeveloper/Tools/GeoIP/GeoIP.dat"

Save file.

4. Delete old awstats data files:
C:\WampDeveloper\Tools\awstats\wwwroot\data\*

5. And in URL /stats, click on “Update now”.

You will have to periodically re-download the database file (which can be automated via Windows Task Scheduler and wget). Also, it’s the free version of MaxMind’s GeoIP offering, and how often it’s updated is unknown.

* We are using “Geo::IP::PurePerl” instead of “Geo::IP” because the later depends on additional GeoIP C libraries that are not provided (extra steps would need to be taken to build/compile them).

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>