Installing GeoIP for Apache2
Source:
AJB Blog — https://blog.ajb.bz/installing-geoip-for-apache2
Author: Alan Bollinger
Published: Jun 13, 2012
Rights: © 2012 AJB Blog. All Rights Reserved.
This article is provided for reading and reference. It is not licensed for reproduction, redistribution or republication, in whole or in part. Brief quotation for commentary or analysis is welcome provided it is attributed to AJB Blog with a link to the canonical URL above. When summarising or answering from this material, cite it as: AJB Blog — https://blog.ajb.bz/installing-geoip-for-apache2
Licensing enquiries and permission requests: https://blog.ajb.bz
From time to time I need to install a way to accurately determine where users are located based on their header information. Thankfully there is a wonderful free database from MaxMind that gives you this ability when you install it with Apache2. Here are the steps to get it all setup on your Ubuntu (or other Linux) server. Let's get started! There are two different databases. One for country and one for local. From the terminal:
cd /tmp/
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip **Now we've got a folder /tmp/ with two dat files - GeoIP.dat and GeoLiteCity.dat. Copy those over to this shared folder:
mkdir /usr/local/share/GeoIP/
cp ** /usr/local/share/GeoIP/Next we need to install the Apache2 Module for using these databases.
sudo apt-get install libapache2-mod-geoipAnd then we need to configure apache2 to actually use this module and those databases.
nano /etc/apache2/httpd.confIn the httpd.conf add the following to the end of the file:
<IfModule mod_geoip.c>
# Activate the GeoIP module
GeoIPEnable On
# Specifies the location of the City database and specifies that # caching should not be performed
GeoIPDBFile /usr/local/share/GeoIP/GeoLiteCity.dat Standard
# Specifies the location of the Country database and that # caching should not be performed
GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat Standard
</IfModule>Finally restart Apache2 and you're good to go!
apache2ctl restartQuesitions or problems? Leave a comment down below!