Installing mod_geoip on cPanel with Easy Apache 4:

mod_geoip Apache module help you to find the location of the IP address of the website visitors. This post describes how to install mod_geoip in cPanel;

Please login to the server via SSH and run the following commands:

yum install GeoIP GeoIP-devel GeoIP-data zlib-devel


Please check the directory /usr/share/GeoIP and verify the data files are there. If the data files are not there, please download them from MaxMind:

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

gunzip GeoIP.dat.gz

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

gunzip GeoLiteCity.dat.gz


Please install the following requirements:

yum install ea-apache24-devel.x86_64 ea-apache24-tools.x86_64 apr


Now compile the mod_geoip Apache module from source:

cd /usr/share/GeoIP/

wget https://github.com/maxmind/geoip-api-mod_geoip2/archive/1.2.10.tar.gz

tar xvzf 1.2.10.tar.gz

cd geoip-api-mod_geoip2-1.2.10/

sed s/remote_ip/client_ip/g -i mod_geoip.c

apxs -i -a -L/usr/lib64 -I/usr/include -lGeoIP -c mod_geoip.c


Open the mod_geoip.conf file:

vi /etc/apache2/conf.modules.d/mod_geoip.conf


Add the following into it:

LoadModule geoip_module /usr/lib64/apache2/modules/mod_geoip.so
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat Standard
GeoIPDBFile /usr/share/GeoIP/GeoLiteCity.dat Standard
</IfModule>


Restart Apache:

service httpd restart


Verify the installation using the following command:

httpd -M | grep geoip

 

 

 

Was this answer helpful? 89 Users Found This Useful (91 Votes)