How To Install mod_geoip On Your WHM/cPanel Server
mod_geoip is an API module released by MaxMind for Apache (or interchangeably, LiteSpeed) to quickly and easily obtain your website visitors’ geographical information. It offers high performance IP lookup especially when used together with PHP. See benchmark
While instructions to install mod_geoip on Linux with Apache are easily available on the Internet, not much is written on how to install the module on WHM/cPanel servers. This tutorial will walk you through installing mod_geoip on your WHM/cPanel step-by-step.
To be able to install mod_geoip on your WHM/cPanel server, you must have root access and is able to SSH to your Virtual Private Server (VPS) / Hyrbrid Server / Dedicated Server. Note that for Shared or Reseller hosting users, you may have to contact your web host to get the module installed for you (warning: don’t expect it to be easy).
You will also need a Telnet / SSH client to log into your VPS. If you haven’t got one, you can download the latest version of PuTTY for free.
Now that you have all the tools ready, let us dive straight into installing mod_geoip on your WHM/cPanel server.
Step 1: Log in to your VPS via SSH and create directory
Open up your SSH client (PuTTY) and log in to your VPS as root user. Then enter the following commands:
# mkdir /usr/share/GeoIP
# cd /usr/share/GeoIP
Step 2: Download and install GeoIP database
To download and install the GeoIP database provided by MaxMind, enter the following commands:
# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
# gzip -d GeoIP.dat.gz
Step 3: Download and install custom mod_geoip module for cPanel
Next we will install the custom mod_geoip cPanel module. Simply enter the following commands:
# wget http://www.rshosting.com/downloads/custom_opt_mod-mod_geoip.tar.gz
# tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-mod_geoip.tar.gz
Step 4: Rebuild Apache via EasyApache
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: Load and enable mod_geoip
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
Second, enter the following codes into the textbox:
LoadModule geoip_module /usr/local/apache/modules/mod_geoip.so
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat MemoryCache
And that’s it! mod_geoip is now installed on your WHM/cPanel server in just 5 simple steps.
[Total: 0 Average: 0/5]