{"id":287,"date":"2016-02-26T01:27:50","date_gmt":"2016-02-26T06:27:50","guid":{"rendered":"http:\/\/underhost.com\/blog\/?p=287"},"modified":"2025-03-12T06:00:17","modified_gmt":"2025-03-12T10:00:17","slug":"geoip-and-mod_geoip-installation-on-cpanel-server","status":"publish","type":"post","link":"https:\/\/underhost.com\/blog\/geoip-and-mod_geoip-installation-on-cpanel-server\/","title":{"rendered":"[Updated 2025] How to Install GeoIP on cPanel Servers"},"content":{"rendered":"<h2> Installing GeoIP on cPanel Servers (Updated 2025)<\/h2>\n<p>GeoIP is a powerful extension that helps detect user location details, including country, city, latitude, longitude, and ISP. If you\u2019re running a cPanel server, you can install GeoIP manually as an Apache module. This guide walks you through the latest installation steps.<\/p>\n<h3> Step 1: Install Required Dependencies<\/h3>\n<p>Before installing GeoIP, ensure you have the required libraries:<\/p>\n<pre><code>yum install GeoIP GeoIP-devel GeoIP-data zlib-devel<\/code><\/pre>\n<h3> Step 2: Create a Directory for GeoIP Database Files<\/h3>\n<p>Next, create a custom installation directory for storing GeoIP database files:<\/p>\n<pre><code>mkdir -p \/usr\/local\/share\/GeoIP<\/code><\/pre>\n<h3> Step 3: Download the Latest GeoIP Databases<\/h3>\n<p>MaxMind no longer offers free GeoLite databases via direct download. Instead, you need to sign up for an account and generate a license key:<\/p>\n<ul>\n<li>Sign up for a free MaxMind account: <a href=\"https:\/\/www.maxmind.com\/en\/geolite2\/signup\" target=\"_blank\">GeoLite2 Signup<\/a><\/li>\n<li>Generate a license key in your MaxMind account.<\/li>\n<li>Download the database using the following commands (replace <code>YOUR_LICENSE_KEY<\/code> with your actual MaxMind license key):<\/li>\n<\/ul>\n<pre><code>\r\ncd \/usr\/local\/share\/GeoIP\r\nwget \"https:\/\/download.maxmind.com\/app\/geoip_download?edition_id=GeoLite2-Country&license_key=YOUR_LICENSE_KEY&suffix=tar.gz\" -O GeoLite2-Country.tar.gz\r\nwget \"https:\/\/download.maxmind.com\/app\/geoip_download?edition_id=GeoLite2-City&license_key=YOUR_LICENSE_KEY&suffix=tar.gz\" -O GeoLite2-City.tar.gz\r\n<\/code><\/pre>\n<p>Extract the database files:<\/p>\n<pre><code>tar -xvzf GeoLite2-Country.tar.gz --strip-components=1\r\ntar -xvzf GeoLite2-City.tar.gz --strip-components=1<\/code><\/pre>\n<h3> Step 4: Install Additional Dependencies<\/h3>\n<p>Install the necessary Apache and APR development packages:<\/p>\n<pre><code>yum install httpd-devel apr-devel<\/code><\/pre>\n<h3> Step 5: Install the mod_geoip Apache Module<\/h3>\n<p>Download and extract the mod_geoip package:<\/p>\n<pre><code>\r\ncd \/usr\/local\/src\r\nwget https:\/\/github.com\/maxmind\/geoip-api-mod_geoip2\/archive\/refs\/tags\/1.2.10.tar.gz -O mod_geoip2.tar.gz\r\ntar -xvzf mod_geoip2.tar.gz\r\ncd geoip-api-mod_geoip2-1.2.10\r\n<\/code><\/pre>\n<p>Build and install the module using APXS:<\/p>\n<pre><code>apxs -i -a -L\/usr\/lib64 -I\/usr\/include -lGeoIP -c mod_geoip.c<\/code><\/pre>\n<h3> Step 6: Configure Apache to Use GeoIP<\/h3>\n<p>Add the following lines to your Apache configuration file <code>\/etc\/httpd\/conf\/httpd.conf<\/code>:<\/p>\n<pre><code>\r\nGeoIPEnable On\r\nGeoIPDBFile \/usr\/local\/share\/GeoIP\/GeoLite2-Country.mmdb\r\nGeoIPDBFile \/usr\/local\/share\/GeoIP\/GeoLite2-City.mmdb\r\n<\/code><\/pre>\n<h3> Step 7: Restart Apache<\/h3>\n<p>Restart the Apache web server to apply the changes:<\/p>\n<pre><code>systemctl restart httpd<\/code><\/pre>\n<h3>How to Verify GeoIP Installation<\/h3>\n<p>To check if the installation was successful, create a <code>phpinfo.php<\/code> file:<\/p>\n<pre><code>\r\necho \"&lt;?php phpinfo(); ?&gt;\" > \/var\/www\/html\/phpinfo.php\r\n<\/code><\/pre>\n<p>Visit <code>http:\/\/yourserver.com\/phpinfo.php<\/code> and search for &#8220;geoip&#8221; to confirm that the module is enabled.<\/p>\n<h3>Need Help? @CustomerPanel Is Here for You<\/h3>\n<p>If you experience issues setting up GeoIP, our <a href=\"https:\/\/customerpanel.ca\/client\">UnderHost Support<\/a> team is available 24\/7. We also offer <a href=\"https:\/\/underhost.com\/dedicated-servers-offshore.php\">dedicated servers<\/a> with pre-installed GeoIP modules.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GeoIP allows websites to detect a visitor\u2019s location based on their IP address. It provides details such as country, city, ISP, and connection type. If you&#8217;re running a cPanel server and need to install GeoIP, follow this updated guide for 2025.<\/p>\n","protected":false},"author":1,"featured_media":4853,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,24],"tags":[],"class_list":["post-287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpinstall","category-install"],"_links":{"self":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":7,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":5154,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/287\/revisions\/5154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media\/4853"}],"wp:attachment":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media?parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/categories?post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/tags?post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}