{"id":287,"date":"2016-02-26T01:27:50","date_gmt":"2016-02-26T06:27:50","guid":{"rendered":"http:\/\/underhost.com\/blog\/?p=287"},"modified":"2026-10-23T08:56:11","modified_gmt":"2026-10-23T12:56:11","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":"IP Geolocation on cPanel: GeoLite2 Setup with PHP, Apache and CSF (2026)"},"content":{"rendered":"<div class=\"uh-blog-hero\" style=\"margin:0 0 40px;text-align:center;padding:48px 24px;border-radius:20px;background:linear-gradient(135deg,#0D1F3C 0%,#125A8A 58%,#176EA5 100%);color:#ffffff;box-shadow:0 20px 40px -15px rgba(13,31,60,0.28);position:relative;overflow:hidden;\">\n<div style=\"display:inline-flex;align-items:center;gap:8px;padding:7px 14px;margin-bottom:16px;border:1px solid rgba(0,212,255,0.32);border-radius:999px;color:#DFF8FF;font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;background:rgba(0,212,255,0.10);\"><i class=\"fas fa-sliders-h\" style=\"color:#00D4FF;\"><\/i> Control Panels<\/div>\n<h1 style=\"color:#ffffff;font-size:clamp(32px,5vw,46px);line-height:1.12;margin:0 0 14px;font-weight:800;\">IP Geolocation on cPanel: GeoLite2 Setup with PHP, Apache and CSF (2026)<\/h1>\n<p style=\"font-size:18px;color:#EAF6FF;max-width:800px;margin:0 auto;line-height:1.7;\">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<\/div>\n<div class=\"uh-blog-excerpt\" style=\"border-left:4px solid #00D4FF;padding:18px 20px;margin:0 0 34px;background:#F8FAFC;color:#1F2937;border-radius:0 14px 14px 0;box-shadow:0 8px 28px rgba(13,31,60,0.08);line-height:1.75;\"><strong style=\"color:#0D1F3C;\">Short answer:<\/strong> Use MaxMind&#8217;s <strong>GeoLite2<\/strong> databases with the current tools: create a free MaxMind account, install <code>geoipupdate<\/code> to download and refresh the databases, then read them with MaxMind&#8217;s PHP library (<code>geoip2\/geoip2<\/code>) or the Apache module <code>mod_maxminddb<\/code>. The old <code>mod_geoip<\/code> and the legacy GeoIP library cannot read GeoLite2 <code>.mmdb<\/code> files, so do not use them on a new setup. If your site is behind Cloudflare, the <code>CF-IPCountry<\/code> header may be all you need.<\/div>\n<nav aria-label=\"Table of contents\" class=\"uh-toc\" style=\"background:#ffffff;border:1px solid #E5E7EB;border-radius:16px;padding:20px 22px;margin:0 0 34px;box-shadow:0 4px 12px rgba(13,31,60,0.08);\">\n<div style=\"font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:#176EA5;margin-bottom:10px;\"><i class=\"fas fa-list\" style=\"color:#00D4FF;\"><\/i> In this guide<\/div>\n<ol style=\"margin:0;padding-left:20px;columns:2 260px;column-gap:28px;line-height:1.9;\">\n<li><a href=\"#what-ip-geolocation-does\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">What IP geolocation does<\/a><\/li>\n<li><a href=\"#common-uses-on-a-hosting-server\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Common uses on a hosting server<\/a><\/li>\n<li><a href=\"#legacy-geoip-and-geolite2-what-changed\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Legacy GeoIP and GeoLite2: what changed<\/a><\/li>\n<li><a href=\"#step-1-create-a-maxmind-account-and-licence-key\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 1: create a MaxMind account and licence key<\/a><\/li>\n<li><a href=\"#step-2-install-geoipupdate-and-download-the-data\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 2: install geoipupdate and download the databases<\/a><\/li>\n<li><a href=\"#step-3-keep-the-databases-up-to-date\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 3: keep the databases up to date<\/a><\/li>\n<li><a href=\"#step-4a-look-up-a-country-in-php\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 4a: look up a country in PHP<\/a><\/li>\n<li><a href=\"#step-4b-use-the-apache-module\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 4b: use the Apache module<\/a><\/li>\n<li><a href=\"#sites-behind-cloudflare\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Sites behind Cloudflare<\/a><\/li>\n<li><a href=\"#country-blocking-with-csf\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Country blocking with CSF<\/a><\/li>\n<li><a href=\"#privacy\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Privacy<\/a><\/li>\n<li><a href=\"#troubleshooting\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Troubleshooting<\/a><\/li>\n<\/ol>\n<\/nav>\n<div class=\"uh-post-content\" style=\"color:#1F2937;font-size:16px;line-height:1.75;\">\n<h2 id=\"what-ip-geolocation-does\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-globe\" style=\"color:#00D4FF;\"><\/i> What IP geolocation does<\/h2>\n<p style=\"margin:0 0 18px;\">IP geolocation looks up an IP address in a database and returns an estimated country, region or city. Websites use it to show local prices or languages, to apply tax rules, to fill in a country on forms, or to block traffic from places they do not serve. Servers use it to block countries at the firewall.<\/p>\n<p style=\"margin:0 0 18px;\">The result is an estimate. Country data is usually reliable, while city data is often wrong or missing. Visitors on a VPN, a mobile network or a corporate proxy may appear somewhere else. Never use geolocation alone for anything that must be exact, such as legal age or identity checks.<\/p>\n<h2 id=\"common-uses-on-a-hosting-server\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-server\" style=\"color:#00D4FF;\"><\/i> Common uses on a hosting server<\/h2>\n<ul style=\"margin:0 0 24px;padding-left:22px;\">\n<li style=\"margin:0 0 8px;\"><strong>Show local content:<\/strong> pick a default language, currency or shipping region from the visitor&#8217;s country, and let visitors change it.<\/li>\n<li style=\"margin:0 0 8px;\"><strong>Fill in forms:<\/strong> pre-select the country on sign-up and checkout forms to save visitors a step.<\/li>\n<li style=\"margin:0 0 8px;\"><strong>Reduce abuse:<\/strong> add extra checks, such as a captcha, for logins from countries where you have no customers.<\/li>\n<li style=\"margin:0 0 8px;\"><strong>Read your traffic:<\/strong> group log entries or analytics by country to see where visitors come from.<\/li>\n<li style=\"margin:0 0 8px;\"><strong>Limit an admin area:<\/strong> allow logins to a control panel or admin page only from the countries where your team works.<\/li>\n<\/ul>\n<h2 id=\"legacy-geoip-and-geolite2-what-changed\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-angle-double-right\" style=\"color:#00D4FF;\"><\/i> Legacy GeoIP and GeoLite2: what changed<\/h2>\n<div style=\"overflow-x:auto;margin:26px 0;border:1px solid #E5E7EB;border-radius:14px;-webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%;border-collapse:collapse;background:#ffffff;color:#1F2937;font-size:15px;line-height:1.55;margin:0;min-width:600px;\">\n<thead>\n<tr style=\"background:#0D1F3C;color:#fff;\">\n<th style=\"padding:14px;text-align:left;\"><\/th>\n<th style=\"padding:14px;text-align:left;\">Legacy GeoIP (old)<\/th>\n<th style=\"padding:14px;text-align:left;\">GeoIP2 and GeoLite2 (current)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Database format<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>.dat<\/code> files<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>.mmdb<\/code> files<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Apache module<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>mod_geoip<\/code><\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>mod_maxminddb<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">PHP access<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">The old <code>geoip<\/code> PECL extension<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">MaxMind&#8217;s <code>geoip2\/geoip2<\/code> library, or the <code>maxminddb<\/code> extension<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Database updates<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Discontinued<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Updated regularly with <code>geoipupdate<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div style=\"background:#FFF7ED;border:1px solid #FDBA74;border-radius:16px;padding:20px 22px;margin:24px 0;\">\n<h3 style=\"margin:0 0 10px;color:#9A3412;font-size:20px;\"><i class=\"fas fa-exclamation-triangle\" style=\"color:#F97316;\"><\/i> Important:<\/h3>\n<p style=\"margin:0;color:#7C2D12;line-height:1.7;\">The legacy tools cannot read GeoLite2 files, and the old free databases are no longer updated. Guides that install <code>mod_geoip<\/code> or download <code>GeoIP.dat<\/code> will give you missing or out-of-date data.<\/p>\n<\/div>\n<h2 id=\"step-1-create-a-maxmind-account-and-licence-key\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 1: create a MaxMind account and licence key<\/h2>\n<ol style=\"margin:0 0 24px;padding-left:22px;\">\n<li style=\"margin:0 0 8px;\">Sign up for a free GeoLite2 account on the MaxMind website.<\/li>\n<li style=\"margin:0 0 8px;\">Log in, open <strong>Manage License Keys<\/strong>, and create a new licence key.<\/li>\n<li style=\"margin:0 0 8px;\">Note your <strong>Account ID<\/strong> and the key. The key is shown only once, so store it in a password manager.<\/li>\n<\/ol>\n<p style=\"margin:0 0 18px;\">Read the GeoLite2 licence terms. Among other things, they require you to keep the database up to date.<\/p>\n<h2 id=\"step-2-install-geoipupdate-and-download-the-data\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-database\" style=\"color:#00D4FF;\"><\/i> Step 2: install geoipupdate and download the databases<\/h2>\n<p style=\"margin:0 0 18px;\"><code>geoipupdate<\/code> is MaxMind&#8217;s official tool for downloading and refreshing databases. Run these commands as root.<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code># AlmaLinux, Rocky Linux, CloudLinux (EPEL, where your release includes it)\ndnf install -y epel-release\ndnf install -y geoipupdate\n\n# Ubuntu and Debian\napt update &amp;&amp; apt install -y geoipupdate<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">If your distribution does not have a package, download the current release from MaxMind&#8217;s geoipupdate page on GitHub. Then edit the configuration file, usually <code>\/etc\/GeoIP.conf<\/code>:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>AccountID 123456\nLicenseKey your_licence_key\nEditionIDs GeoLite2-Country GeoLite2-City<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Protect the file so only root can read it, then download the databases:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>chmod 600 \/etc\/GeoIP.conf\ngeoipupdate -v\nls -l \/usr\/share\/GeoIP\/      # the folder is set by DatabaseDirectory in GeoIP.conf<\/code><\/pre>\n<h2 id=\"step-3-keep-the-databases-up-to-date\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-database\" style=\"color:#00D4FF;\"><\/i> Step 3: keep the databases up to date<\/h2>\n<p style=\"margin:0 0 18px;\">MaxMind updates GeoLite2 several times a month. Add a cron job so your copy stays current:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code># \/etc\/cron.d\/geoipupdate  (runs every Wednesday and Saturday at 03:15)\n15 3 * * 3,6 root \/usr\/bin\/geoipupdate<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Check the path with <code>which geoipupdate<\/code>. Some packages add their own timer, so check <code>systemctl list-timers<\/code> before you add a second job.<\/p>\n<h2 id=\"step-4a-look-up-a-country-in-php\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 4a: look up a country in PHP<\/h2>\n<p style=\"margin:0 0 18px;\">This is the simplest option for most cPanel websites. In the site folder, install the library with Composer:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>cd ~\/public_html\ncomposer require geoip2\/geoip2<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Then look up the visitor&#8217;s country:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>&lt;?php\nrequire __DIR__ . '\/vendor\/autoload.php';\n\nuse GeoIp2\\Database\\Reader;\n\n$reader = new Reader('\/usr\/share\/GeoIP\/GeoLite2-Country.mmdb');\ntry {\n    $record = $reader-&gt;country($_SERVER['REMOTE_ADDR']);\n    echo $record-&gt;country-&gt;isoCode;   \/\/ for example \"TH\" or \"US\"\n} catch (GeoIp2\\Exception\\AddressNotFoundException $e) {\n    echo 'unknown';\n}<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">On shared hosting, the database folder may not be readable by your account. Ask support where the server&#8217;s copy is, or keep your own copy outside <code>public_html<\/code> and update it with <code>geoipupdate<\/code> from a cron job.<\/p>\n<h2 id=\"step-4b-use-the-apache-module\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 4b: use the Apache module<\/h2>\n<p style=\"margin:0 0 18px;\"><code>mod_maxminddb<\/code> adds the location to Apache environment variables, so rewrite rules and applications can use it without code changes. On a cPanel server, check EasyApache 4 for a packaged module first. A module built by hand can break when EasyApache updates Apache. Once the module is loaded, a configuration looks like this:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>&lt;IfModule mod_maxminddb.c&gt;\n    MaxMindDBEnable On\n    MaxMindDBFile COUNTRY_DB \/usr\/share\/GeoIP\/GeoLite2-Country.mmdb\n    MaxMindDBEnv MM_COUNTRY_CODE COUNTRY_DB\/country\/iso_code\n&lt;\/IfModule&gt;<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Applications can then read <code>MM_COUNTRY_CODE<\/code> from the environment.<\/p>\n<h2 id=\"sites-behind-cloudflare\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-angle-double-right\" style=\"color:#00D4FF;\"><\/i> Sites behind Cloudflare<\/h2>\n<p style=\"margin:0 0 18px;\">If the site uses Cloudflare, turn on IP Geolocation in the Cloudflare dashboard. Cloudflare then sends the visitor&#8217;s country in the <code>CF-IPCountry<\/code> header, and you do not need a database on the server. Also make sure the server logs and your application see the real visitor IP, not Cloudflare&#8217;s. Our <a href=\"https:\/\/underhost.com\/blog\/the-best-way-to-use-cloudflare-with-cpanel-whm-for-better-performance\/\">Cloudflare and cPanel guide<\/a> explains the setup.<\/p>\n<h2 id=\"country-blocking-with-csf\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-angle-double-right\" style=\"color:#00D4FF;\"><\/i> Country blocking with CSF<\/h2>\n<p style=\"margin:0 0 18px;\">To block or allow whole countries at the firewall, use CSF instead of the web server. In <code>\/etc\/csf\/csf.conf<\/code>, choose a country data source with <code>CC_SRC<\/code>. If you choose MaxMind, enter your licence key in <code>MM_LICENSE_KEY<\/code>. Then list country codes in <code>CC_DENY<\/code> or <code>CC_ALLOW<\/code>, and restart CSF. Large country lists use a lot of memory, so block only what you need. See our <a href=\"https:\/\/underhost.com\/blog\/how-to-install-and-configure-csf-firewall-on-your-server\/\">CSF firewall guide<\/a> for the basics.<\/p>\n<h2 id=\"privacy\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-angle-double-right\" style=\"color:#00D4FF;\"><\/i> Privacy<\/h2>\n<p style=\"margin:0 0 18px;\">IP addresses can be personal data under laws such as the GDPR. Store only what you need, for example the country code rather than the full IP address, and mention location lookups in your privacy policy.<\/p>\n<h2 id=\"troubleshooting\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-exclamation-triangle\" style=\"color:#00D4FF;\"><\/i> Troubleshooting<\/h2>\n<div style=\"overflow-x:auto;margin:26px 0;border:1px solid #E5E7EB;border-radius:14px;-webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%;border-collapse:collapse;background:#ffffff;color:#1F2937;font-size:15px;line-height:1.55;margin:0;min-width:600px;\">\n<thead>\n<tr style=\"background:#0D1F3C;color:#fff;\">\n<th style=\"padding:14px;text-align:left;\">Problem<\/th>\n<th style=\"padding:14px;text-align:left;\">Likely cause<\/th>\n<th style=\"padding:14px;text-align:left;\">Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>geoipupdate<\/code> fails with an authentication error<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Wrong Account ID or licence key<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Check both values in GeoIP.conf, or create a new key.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Every visitor shows the same country<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">The site sees a proxy or Cloudflare IP<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Restore the real visitor IP, or use the CF-IPCountry header.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">PHP error: file not found or not readable<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Wrong path, or the account cannot read the folder<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Check the path and permissions, or keep a copy inside your home folder.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Results look out of date<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">The update job is not running<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Run <code>geoipupdate -v<\/code> by hand and check the cron job or timer.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div aria-hidden=\"true\" class=\"uh-section-divider\" style=\"width:min(100% - 32px, 1080px);margin:44px auto;display:grid;grid-template-columns:1fr 32px 1fr;align-items:center;gap:18px;pointer-events:none;\"><span style=\"height:1px;background:linear-gradient(90deg,transparent,rgba(0,212,255,0.40),rgba(23,110,165,0.24),transparent);\"><\/span><img alt=\"\" decoding=\"async\" height=\"32\" loading=\"lazy\" src=\"https:\/\/cdn.underhost.com\/android-chrome-192x192.webp\" style=\"width:32px;height:32px;display:block;border-radius:8px;filter:drop-shadow(0 0 14px rgba(0,212,255,0.30));\" width=\"32\"\/><span style=\"height:1px;background:linear-gradient(90deg,transparent,rgba(23,110,165,0.24),rgba(0,212,255,0.40),transparent);\"><\/span><\/div>\n<\/div>\n<div class=\"uh-blog-cta\" style=\"background:linear-gradient(135deg,#0D1F3C 0%,#125A8A 58%,#176EA5 100%);color:#ffffff;padding:36px 24px;border-radius:20px;text-align:center;margin:44px 0;box-shadow:0 20px 40px -15px rgba(13,31,60,0.32);\">\n<h2 style=\"margin:0 0 12px;font-size:28px;line-height:1.25;color:#ffffff;\">Need help with this?<\/h2>\n<p style=\"font-size:17px;margin:0 auto 22px;color:#EAF6FF;max-width:720px;line-height:1.7;\">Need GeoLite2 or country blocking set up on your server? Our team can install and configure it for you.<\/p>\n<p><a href=\"https:\/\/underhost.com\/server-management.php\" style=\"background:linear-gradient(90deg,#00D4FF,#0077FF);color:#ffffff;padding:13px 28px;border-radius:10px;text-decoration:none;font-weight:800;display:inline-block;margin:8px;\">See server management plans<\/a><a href=\"https:\/\/customerpanel.ca\/client\/\" style=\"background:transparent;color:#ffffff;padding:12px 28px;border-radius:10px;text-decoration:none;font-weight:800;display:inline-block;margin:8px;border:1px solid rgba(255,255,255,0.32);\">Contact @CustomerPanel<\/a><\/div>\n<div class=\"uh-faq-section\" id=\"faq\" style=\"margin:34px 0;scroll-margin-top:90px;\">\n<h2 style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:0 0 18px;border-bottom:2px solid rgba(0,212,255,0.22);padding-bottom:10px;\">Frequently asked questions<\/h2>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Can I still use mod_geoip on cPanel?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">It is not recommended. mod_geoip reads only the legacy .dat format, which MaxMind no longer updates. Use mod_maxminddb or the PHP library with GeoLite2 databases.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Is GeoLite2 free?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Yes. GeoLite2 is free with a MaxMind account and licence key, under MaxMind&#8217;s licence terms. MaxMind also sells more accurate GeoIP2 databases.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">How accurate is IP geolocation?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Country results are usually accurate. City results are less reliable, and VPNs, proxies and mobile networks can show a visitor in the wrong place.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">How often should I update the GeoLite2 databases?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Once or twice a week with geoipupdate. MaxMind&#8217;s licence requires you to keep the database up to date.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Can I block countries without changing my website?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Yes. Use CSF country blocking with CC_DENY or CC_ALLOW, or use Cloudflare&#8217;s firewall rules if the site is behind Cloudflare.<\/p>\n<\/div>\n<\/div>\n<p><!-- uh-related-start --><\/p>\n<div style=\"background:#F4F8FC;border:1px solid #DCE7F3;border-radius:14px;padding:18px 22px;margin:32px 0 8px;\">\n<h2 style=\"margin:0 0 12px;font-size:22px;\">Related guides<\/h2>\n<ul style=\"margin:0;padding-left:20px;\">\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/install-gmp-cpanel-centos-servers\/\">How to Install GMP on a cPanel Server (EasyApache 4)<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/essential-free-cpanel-plugins-for-server-management\/\">Essential Free cPanel Plugins for Server Management<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/how-to-configure-modsecurity-in-cpanel-for-advanced-security\/\">How to Configure ModSecurity in cPanel for Advanced Security<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/how-to-install-clamav-cpanel\/\">How to Install and Use ClamAV Antivirus in WHM\/cPanel<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/cpanel-setup-secure-and-plugins-installer\/\">cPInstall: Legacy cPanel Automation Script (Do Not Use)<\/a><\/li>\n<\/ul>\n<\/div>\n<p><!-- uh-related-end --><br \/>\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Can I still use mod_geoip on cPanel?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"It is not recommended. mod_geoip reads only the legacy .dat format, which MaxMind no longer updates. Use mod_maxminddb or the PHP library with GeoLite2 databases.\"}}, {\"@type\": \"Question\", \"name\": \"Is GeoLite2 free?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Yes. GeoLite2 is free with a MaxMind account and licence key, under MaxMind's licence terms. MaxMind also sells more accurate GeoIP2 databases.\"}}, {\"@type\": \"Question\", \"name\": \"How accurate is IP geolocation?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Country results are usually accurate. City results are less reliable, and VPNs, proxies and mobile networks can show a visitor in the wrong place.\"}}, {\"@type\": \"Question\", \"name\": \"How often should I update the GeoLite2 databases?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Once or twice a week with geoipupdate. MaxMind's licence requires you to keep the database up to date.\"}}, {\"@type\": \"Question\", \"name\": \"Can I block countries without changing my website?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Yes. Use CSF country blocking with CC_DENY or CC_ALLOW, or use Cloudflare's firewall rules if the site is behind Cloudflare.\"}}]}<\/script><\/p>\n<h2 id=\"sources\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-book\" style=\"color:#00D4FF;\"><\/i> Sources<\/h2>\n<ul style=\"margin:0 0 24px;padding-left:22px;\">\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/dev.maxmind.com\/geoip\/geolite2-free-geolocation-data\">MaxMind: GeoLite2 free geolocation data<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/dev.maxmind.com\/geoip\/updating-databases\">MaxMind: updating databases with geoipupdate<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/github.com\/maxmind\/GeoIP2-php\">MaxMind GeoIP2 PHP API<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/github.com\/maxmind\/mod_maxminddb\">MaxMind mod_maxminddb<\/a><\/li>\n<\/ul>\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":[3,202,81],"tags":[161,108,137,185],"class_list":["post-287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-control-panels","category-cpanel-whm","category-hosting-guides","tag-cloudflare","tag-tag-cpanel","tag-tag-firewall","tag-php"],"_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":15,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":6950,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/287\/revisions\/6950"}],"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}]}}