How-TO: MaxMind GeoIP for Awstats

gunemalli

Verified User
Joined
Jul 22, 2009
Messages
86
Location
Sheffield, UK
The latest versions of DA comes with awstats but when i was looking in the stats generated, there were no countries identified. So i went looking for solutions and mgot my system work.

So I'm now sharing the information with you on what i did to get it working with existing users and new users alike.

Prerequisite
  • DirectAdmin ;)
  • Awstats (tested on 6.95)
  • C/C++
  • Perl

run the following as root
Code:
wget http://simplispace.com/downloads/geoip.sh
chmod 0755 geoip.sh
./geoip.sh

And you're done. here's breakdown on what this script does.
  • Downloads GeoIP databases
  • Downloads GeoIP C and Pearl sources
  • Build and install GeoIP C and Pearl Modules
  • Download modified awstats.model.conf from simplispace.com *
  • erase all users' awstats.DOMAIN.conf file
  • recreate all awstats conf files
  • clean up the files

* The only config change from the default DA installation is DNSLookup is set to 0 (orignally 2)(For performance) the lines needed to run the plugin.

Hope you enjoyed this. Please send me your feedbacks here.

Sources:
http://antezeta.com/awstats/geoip.html
http://wiki.jaumesola.com/DirectAdmin/AWStats

SideNote:
This script is in a such a state that it could be integrated DA's Awstats installation/update scripts with very little tweaking.
 
Last edited:
Thanks for the script, but I think you should pay more attention the the requirements list, because now it's misleading. Your "pearl" on the list could mean pear or perl, because I don't think that GeoIP or your script requires Process and Experiment Automation Realtime Language (PEARL: http://en.wikipedia.org/wiki/PEARL_(programming_language)).

Thanks for correcting me. It should be perl and the 1st post is updated to reflect this. I always get confused the letters as the the correct one is 'pearl' and the programming language is 'perl'.
 
If there is error like that,

Code:
Error: Plugin load for plugin 'geoip' failed with return code: Error: Can't locate Geo/IP.pm in @INC
...
Error: Need Perl module Geo::IP or Geo::IP::PurePerl

please install the following perl addon
cpan -i YAML;
cpan -i Geo::IP Geo::IP::purePerl
 
Hello Asanka,

Add this line to your script to delete AWSTATS configurations also in subdomains:

Code:
rm -f /home/*/domains/*/awstats/*/.data/awstats.*.conf

In my case compiling GeoIP gave me several errors:
Code:
]# make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /home/mantenimiento/GeoIP-1.4.8/missing --run aclocal-1.11
 cd . && /bin/sh /home/mantenimiento/GeoIP-1.4.8/missing --run automake-1.11 --gnu
libGeoIP/Makefile.am:1: Libtool library used but `LIBTOOL' is undefined
libGeoIP/Makefile.am:1:   The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
libGeoIP/Makefile.am:1:   to `configure.in' and run `aclocal' and `autoconf' again.
libGeoIP/Makefile.am:1:   If `AC_PROG_LIBTOOL' is in `configure.in', make sure
libGeoIP/Makefile.am:1:   its definition is in aclocal's search path.
make: *** [Makefile.in] Error 1

For me it was easier to install using yum from EPEL repositories:
Code:
yum install GeoIP GeoIP-devel perl-Geo-IP
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centosr3.centos.org
 * epel: mirror.nl.leaseweb.net
 * extras: centosr3.centos.org
 * rpmforge: apt.sw.be
 * updates: centosn4.centos.org
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package GeoIP.x86_64 0:1.4.8-1.el6 will be installed
---> Package GeoIP-devel.x86_64 0:1.4.8-1.el6 will be installed
---> Package perl-Geo-IP.x86_64 0:1.38-6.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                               Arch                             Version                                  Repository                      Size
======================================================================================================================================================
Installing:
 GeoIP                                 x86_64                           1.4.8-1.el6                              epel                           620 k
 GeoIP-devel                           x86_64                           1.4.8-1.el6                              epel                            11 k
 perl-Geo-IP                           x86_64                           1.38-6.el6                               epel                            84 k

Transaction Summary
======================================================================================================================================================
Install       3 Package(s)

regards
 
Last edited:
Back
Top