Requisites: Apache module, mod_maxminddb, libmaxminddb

INSTRUCTIONS:

1.Download and install libmaxminddb

[root@pidev ~]# git clone --recursive https://github.com/maxmind/libmaxminddb
[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 https://github.com/maxmind/mod_maxminddb/archive/master.zip
[root@pidev ~]# unzip master.zip
[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

http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.Tar.gz
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

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
  • By admin
  • in DevOps

Best DevOps Tools You Must Try in 2022

  • Jul 26, 2022 .
  • 12 min min
Read More

Be in the know

Techno tips served hot! Subscribe now and stay atop.