Created
November 8, 2013 20:54
-
-
Save plasticbrain/7377533 to your computer and use it in GitHub Desktop.
Install MaxMind's GeoIP modules for Apache (on Ubuntu)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I. Prerequisites | |
$ apt-get install apache2-prefork-dev | |
$ apt-get install apache2-threaded-dev | |
$ apt-get install libgeoip-dev | |
1. Download and install mod_geoip2 | |
http://www.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2-latest.tar.gz | |
$ tar xvfz mod_geoip2-latest.tar.gz | |
$ cd mod_geoip_#.#.# | |
$ apxs2 -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c mod_geoip.c | |
2. Download and extract the .dat file from maxmind | |
$ tar xvfz GeoIP2-Country_20131029.tar.gz | |
$ cd GeoIP2-Country_20131029.tar.gz | |
$ mv GeoIP....dat /var/geoip.dat | |
3. Load the module in Apache | |
$ nano /etc/apache2/conf.d | |
(OR /etc/apach2/apache2.conf) | |
Copy/Paste: | |
<IfModule mod_geoip.c> | |
GeoIPEnable On | |
GeoIPDBFile /var/geoip.dat | |
</IfModule> | |
4. Restart Apache | |
$service apache2 reload | |
5. Test for the geoip variables in the $_SERVER data | |
<?php var_dump($_SERVER); ?> | |
GEOIP_ADDR | |
GEOIP_COUNTRY_CODE | |
GEOIP_COUNTRY_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment