• 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 401 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 (24.3K 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

  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023

About This Article

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

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

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

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

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT