GeoLocation How To: Install MaxMind mod_GeoIP2 on Apache in 15 Hair-Raising Steps

Here are the exact 15 steps I take every single time I install this thing.


  • Apache 2.x
  • Cpanel
  • You have shell access as root



  • Step 3 – Upload both to server as root, login via SSH as root, go to where you put these files and gunzip both, then “tar -xvf” both.
  • Step 4 – Go into directory where you just uncompressed the C API to, and execute this (pay attention to leading dot):
 ./configure; make; make install
  • Step 5 – Go into the directory for the Apache module and execute this:
apxs -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c mod_geoip.c
  • Step 6 – Take a look, there is now a line that talks about mod_geoip
 cat /usr/local/apache/conf/httpd.conf |more
  • Step 7 – Update distiller with the changes the intaller just made to the Apache configuration (note there is a double-dash “–” before “update”)
/usr/local/cpanel/bin/apache_conf_distiller --update
  • Step 8 – Rebuild the config file
  • Step 9 – Make sure the changes stuck around and didn’t get wiped
cat /usr/local/apache/conf/httpd.conf |more
  • Step 10 – Make a backup of httpd.conf
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd-RestoreThisOneIdiot.conf.bkp
  • Step 11 – Add this to your httpd.conf – Note that these are my preferences for settings
<IfModule mod_geoip.c>
  GeoIPEnable On
  GeoIPDBFile /usr/local/share/GeoIP/GeoLiteCity.dat IndexCache
  GeoIPScanProxyHeaders On
  • Step 12 – Rebuild the config file (again)
/usr/local/cpanel/bin/apache_conf_distiller --update
  • Step 13 – Make sure the changes stuck around and didn’t get wiped (again)
 cat /usr/local/apache/conf/httpd.conf |more
  • Step 14 – Enter the following commands to get the latest City-level database in the right place
cd /usr/local/share/GeoIP/
 gunzip -f -c GeoLiteCity.dat.gz > GeoLiteCity.dat
  • Step 15 – Go into Cpanel and restart Apache
  • Bonus Step – Drink Martini. Make note to invite me one at ASC 2012 or ASW 2013!