• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Installing GeoIP Module On Apache2, Ubuntu 16.04

By Abhishek Ghosh June 8, 2017 8:51 pm Updated on June 8, 2017

Installing GeoIP Module On Apache2, Ubuntu 16.04

Advertisement

We did it before but for Nginx (you can look – Installing GeoIP On Nginx). We need this to use GoAcesss log analyzer like tools, Piwik etc. WordPress like modern CMS use PHP based function and needs no server side work. Installing GeoIP Module On Apache2, Ubuntu 16.04 Needs Some Manual Steps After Running Installation Command. Sample PHP file supplied to test.

Installing GeoIP Module On Apache2, Ubuntu 16-04

 

Installing GeoIP Module On Apache2, Ubuntu 16.04

 

As there is an Apache Module, installing GeoIP on Apache2 is far easier compared to Nginx. If you run

Vim
1
apt search geoip

You’ll get libapache2-mod-geoip apart from other packages. In order to install properly, run :

Advertisement

---

Vim
1
2
3
apt update
apt upgrade
apt install geoip-bin geoip-database libapache2-mod-geoip libgeoip1

In newer Apache, modules automatically get activated, manual work not needed. The Geo files are at this location :

Vim
1
/usr/share/GeoIP/

Those files need update by manual works.

You need to download the databases from here :

Vim
1
https://dev.maxmind.com/geoip/legacy/geolite/

Do these steps :

/usr/share/GeoIP/
Vim
1
2
3
4
5
6
7
8
9
10
cd /usr/share/GeoIP/
ls
rm GeoIP.dat
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
gunzip GeoIPASNum.dat.gz
ls

The Apache GeoIP Module configuration file is located here :

Vim
1
/etc/apache2/mods-enabled/geoip.conf

Open it :

Vim
1
nano /etc/apache2/mods-enabled/geoip.conf

For our above steps, the file after editing should look like this :

Vim
1
2
3
4
5
6
<IfModule mod_geoip.c>
  GeoIPEnable On
  GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
  GeoIPDBFile /usr/share/GeoIP/GeoLiteCity.dat
  GeoIPDBFile /usr/share/GeoIP/GeoIPASNum.dat
</IfModule>

Save the file. You’ll notice that the file has warning :

Vim
1
2
3
  # For performance reasons, it's not recommended to turn GeoIP on serverwide,
  # but rather only in <Location> or <Directory> blocks where it's actually
  # needed.

We are keeping on as we need for works like server log analysis. That module’s documentation is available on GitHub :

Vim
1
https://github.com/maxmind/geoip-api-mod_geoip2

The module has hundreds of odd matters, unless you need, keep the status to off. Run configtest and restart the server :

Vim
1
2
apachectl -t
sudo systemctl restart apache2.service

Now, go to your FTP public directory location and wget my script which I kept here on GitHub.Alternatively, you can create a file with some name like geotest.php and copy-paste this content :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
<body>
<?php
 
$geoip_country_code = getenv(GEOIP_COUNTRY_CODE);
$geoip_country_name = getenv(GEOIP_COUNTRY_NAME);
$geoip_region = getenv(GEOIP_REGION);
$geoip_city = getenv(GEOIP_CITY);
$geoip_postal_code = getenv(GEOIP_POSTAL_CODE);
$geoip_latitude = getenv(GEOIP_LATITUDE);
$geoip_longitude = getenv(GEOIP_LONGITUDE);
 
 
echo 'Country code: '.$geoip_country_code.'<br>';
echo 'Country name: '.$geoip_country_name.'<br>';
echo 'Region: '.$geoip_region.'<br>';
echo 'City: '.$geoip_city.'<br>';
echo 'Postal code: '.$geoip_postal_code.'<br>';
echo 'Latitude: '.$geoip_latitude.'<br>';
echo 'Longitude: '.$geoip_longitude.'<br>';
 
?>
</body>
</html>

Now open URL to point to that file on browser, you will see some information about your ISP like :

Vim
1
2
3
4
5
6
7
Country code: IT
Country name: Italy
Region: 16
City: Arezzo
Postal code: 52100
Latitude: 43.416698
Longitude: 11.883300

That means installation is correct.

Tagged With apache geoip error opening file geolitecity dat , Apache Ubuntu geoip , apache2 geoip module , geoip apache module , geoip install apache ubuntu , geoip with apache on ubuntu , https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1829 0Gtv_0WshjtJEn5P-dL3HmIwUhrTJiNlFQKKu9d_SfQ9BhQOhQGTq-p1nNgSzigI dd66c0c8232ba2e320e17554b07029074d46a9ce&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme , install geoip-bin on Ubuntu , installer mod_geoip apache kubuntu

This Article Has Been Shared 268 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Installing GeoIP Module On Apache2, Ubuntu 16.04

  • Cloud Computing Agility : The Converged Technologies

    Cloud Computing Agility is a characteristic feature of Cloud which allows to gain the speed in development and deployment of applications and Services.

  • Steaming iTunes Music Server on Cloud Platform

    Steaming iTunes Music Server on Cloud Platform can be setup without paying for the dedicated hardware. Here is the detailed ways of the possible solution.

  • How to Make Cloud Computing Secure ?

    How to Make Cloud Computing Secure ? Keep an eye on the provider’s choice ! Here are a few tips to check while you are in need of Secure Cloud Computing.

  • Keyless Door Unlocking Mobile Cloud Based Apps : Gaining More Interest

    Keyless Door Unlocking Mobile Cloud Based Apps like Lockitron, ShareKey are growing interest from both the developers and the users. Let us have a deeper look.

  • Cloud Security Solutions for Tablets and Smartphones

    Cloud Security Solutions for Tablets and Smartphones covers the issues with lost or stolen mobile devices, accidental data deletion, App security and Malwares.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (22.1K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • How Artificial Intelligence (AI) Is Changing The Way We Play Bingo May 16, 2022
  • Why You Need A Big Data Consultant May 15, 2022
  • The Connection Between AI And Online Slots May 13, 2022
  • How To Choose Your Niche As An Instagram Influencer May 12, 2022
  • How to Choose a Powerful Domain Name for Your New Venture May 12, 2022

About This Article

Cite this article as: Abhishek Ghosh, "Installing GeoIP Module On Apache2, Ubuntu 16.04," in The Customize Windows, June 8, 2017, May 16, 2022, https://thecustomizewindows.com/2017/06/installing-geoip-module-apache2-ubuntu-16-04/.

Source:The Customize Windows, JiMA.in

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Privacy Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2022 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy