How can I install mod_geoip on my cPanel server?
Please note while cPanel does not provide the mod_geoip module or the database files, it is possible to install mod_geoip for your cPanel server.
You will first need to register with MaxMind for an account in order to download the GeoLite2 free database. You can sign up here. MaxMind Geolite2
Next, on the cPanel server, install GeoIP and install the GeoIP packages from Pecl.
$ yum install GeoIP GeoIP-devel
For PHP 5.4 through 5.6, replacing X with your version, you can run:
$ /usr/bin/ea-php5X-pecl install geoip
For 7 and above:
$ /usr/bin/ea-php7X-pecl install geoip-1.1.1
Once the installation has completed for each PHP version you need this installed for, download the databases from the MaxMind site to
$ cd /usr/share/GeoIP
Next, we need to acquire the Geo City data and the GeoIP ASN from Maxmind by downloading the database files and restarting Apache.
As an example:
$ curl -I 'https://download.maxmind.com/app/geoip_download?edition_id=GeoIP2-City-CSV&license_key=YOUR_LICENSE_KEY&suffix=zip'
When the database downloads have completed, gunzip the files and restart Apache.
This will complete the mod_geoip installation.