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.
Assumptions:
- Apache 2.x
- Cpanel
- You have shell access as root
Instructions:
- Step 1 – Download the C API from http://www.maxmind.com/app/c
Specifically:
http://geolite.maxmind.com/download/geoip/api/c/
- Step 2 – Download Apache module from: http://www.maxmind.com/app/mod_geoip
Specifically:
http://geolite.maxmind.com/download/geoip/api/mod_geoip2/
- 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
/usr/local/cpanel/bin/build_apache_conf
- 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 </IfModule>
- Step 12 – Rebuild the config file (again)
/usr/local/cpanel/bin/apache_conf_distiller --update
/usr/local/cpanel/bin/build_apache_conf
- 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/ wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip -f -c GeoLiteCity.dat.gz > GeoLiteCity.dat
- Step 15 – Go into Cpanel and restart Apache
dean 6:05 pm on August 3, 2012 Permalink |
hey,
how do I know if my host is using Apache?