mod_geoip Install On a WHM/cPanel Server

Step 1:

mkdir /usr/share/GeoIP
cd /usr/share/GeoIP

Step 2:

Download and install the GeoIP database provided by MaxMind, enter the following commands:
gzip -d GeoIP.dat.gz

Step 3:
Install the custom mod_geoip cPanel module.

wget wget
tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-mod_geoip.tar.gz

Step 4:

Now that we have installed the GeoIP database and all the modules required to run mod_geoip with Apache and cPanel, we will need to rebuild Apache in WHM.

WHM -> Software -> EasyApache (Apache Update) -> Start customizing based on profile -> Check ‘Mod GeoIP’ option (on Short / Exhaustive Options List page) -> Save and Build

Step 5:

After Apache has been rebuilt with mod_geoip, we will need to load and enable the module every time Apache runs. First, in WHM, go to:

WHM -> Service Configuration -> Apache Configuration -> Include Editor -> Pre Main Include -> Select the current Apache version

LoadModule geoip_module /usr/local/apache/modules/
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat MemoryCache


httpd -m | grep -i geoip