Requisites: Apache module, mod_maxminddb, libmaxminddb


1.Download and install libmaxminddb

[root@pidev ~]# git clone --recursive
[root@pidev ~]# cd libmaxminddb
[root@pidev libmaxminddb]# ./bootstrap
[root@pidev libmaxminddb]# ./configure
2.Run the following

[root@pidev libmaxminddb]# make
[root@pidev libmaxminddb]# make install

3. Download and install the Apache module mod_maxminddb

[root@pidev ~]# wget
[root@pidev ~]# unzip
[root@pidev ~]# cd mod_maxminddb-master
[root@pidev mod_maxminddb-master]# ./bootstrap

4. Next,configure by specifying the full path of apxs

[root@pidev mod_maxminddb-master]# ./configure --with-apxs=/usr/sbin/apxs
[root@pidev mod_maxminddb-master]# make
[root@pidev mod_maxminddb-master]# make install

5.Download and extract GeoLite Country database
Note the path of GeoLite2-Country.mmdb file.

6.Make sure you restart Apache web server.

[root@pidev ~]#/etc/init.d/httpd restart

7.Lastly add the following in the domain’s .htaccess file (replace the full file path of GeoLite2-Country.mmdb in the server)
MaxMindDBEnable On
MaxMindDBFile DB /usr/share/GeoIP/GeoLite2-Country_20170905/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
#The below code will block access from Australia and France
SetEnvIf MM_COUNTRY_CODE ^(AU|FR) BlockCountry
Deny from env=BlockCountry
Get new insights right to your inbox

How can our experts help you?

Schedule your consultation

You may also like

  • By admin
  • in DevOps

Agile vs DevOps: What’s the difference

  • Nov 18, 2022 .
  • 9 min min
Read More
  • By admin
  • in DevOps

DevOps as a Service: All You Should Know

  • Aug 9, 2022 .
  • 9 min min
Read More
  • By admin
  • in Containerization

Containerization VS Virtualization: Understanding the Differences

  • Aug 4, 2022 .
  • 8 min min
Read More

Be in the know

Techno tips served hot! Subscribe now and stay atop.