# Solved: How to Install GeoLite2-City IP Lookup DB

**URL:** https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199
**Category:** Product Support
**Created:** [April 10, 2016, 7:45pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199 "2016-04-10T19:45:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![CraigM](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@CraigM](https://forum.mautic.org/u/CraigM)
#### Post date: [April 10, 2016, 7:45pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199/1 "2016-04-10T19:45:36Z")

</div>

These are the step by step instructions I used to install MaxMinds’s GeoLite2-City database with monthly updates on Hostgator.  
  
  
  
MxyzptlkFishStix deserves a big round of applause for his help!  
  
  
  
  
  
**How to Obtain and update MaxMinds’s GeoLite2-City database.**  
  
  
  
**1.** Go to [http://dev.maxmind.com/geoip/geoip2/geolite2/](http://dev.maxmind.com/geoip/geoip2/geolite2/) and download (to your pc) the “MaxMind DB binary, gzipped” version.  
  
  
  
**2.** Extract the resulting file from GeoLite2-City.mmdb.gz to GeoLite2-City.mmdb using PKZip or other compression utility.  
  
  
  
**3.** Copy (ftp) the file GeoLite2-City.mmdb to your server: (directory-structure)/public\_html/mautic/app/cache/ip\_data  
  
  
  
**Note:** Modifying (directory-structure) to reflect your server’s directory structure. Your directory structure can be determined in your C Panel under “Account Information” or by using your C Panel’s File Manager. In File Manager at the top of the Directory tree (on the left) you will see a little house Icon. That is your (directory structure).  
  
  
  
**Note:** I copied (ftp) the file to ensure that I was able to create the file in the ip\_data directory which should already be present under the current release of Mautic. If the ip\_data directory does not exist, create it.  
  
  
  
**Create the update-maxmind-database update file to be used monthly when updating the GeoLite2-City.mmdb**  
  
  
  
**1.** Create a blank update-maxmind-database.txt file in notepad and paste the following into it modifying (directory-structure) to reflect your server directory structure.

Code:

#!/bin/bash wget -N -P (directory-structure)/public\_html/mautic/app/cache/ip\_data http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz gunzip -f (directory-structure)/public\_html/mautic/app/cache/ip\_data/\*.gz

  
**2.** Save the file as update-maxmind-database.txt  
  
**3.** Copy (ftp) the update-maxmind-database.txt to the (directory-structure) directory. In my case I put it in the root directory.  
  
**4.** Rename your file (update-maxmind-database.txt) it removing the .txt to update-maxmind-database using the File Manager from your C Panel.  
  
**5.** Change the file permissions to full read, write, execute permissions using the File Manager from your C Panel.  
  
  
**Create a new Cron Job from within your C Panel as follows:**  
  
**1.** Enter your Cron Jon Command string as follows:  

Code:

(directory-structure)/update-maxmind-database

  
**Note:** Modify (directory-structure) to reflect your server directory structure.  
  
**2.** Set Cron Job to run every 5 minutes.  
  
**3.** Delete the database file: (directory-structure)/public\_html/mautic/app/cache/ip\_data/GeoLite2-City.mmdb.  
  
**4.** Let the Cron job run.  
  
**5.** Check the resulting Cron Job notification email to ensure that the database downloaded and extracted from .gz to .mmdb  
  
**6.** Check that the database file was created: (directory-structure)/public\_html/mautic/app/cache/ip\_data/GeoLite2-City.mmdb.  
  
**Note:** The database file may have the same creation date as the original you deleted. The file date will change monthly as new .mmdb files are created by MaxMind.  
  
**7.** Add the suffix to the right end of the Cron Job to suppress error logs.  

Code:

\>/dev/null 2\>&1

  
**8.**** _Change Cron Job to run sometime after the first Tuesday of each month. This is to reflect MaxMinds, database updates on the first Tuesday of each month_**.  
  
**Note:** The current database in your file structure is overwritten each time the Cron Job runs. No additonal files are created and the .gz file is removed as well. Once the Cron Job is running no additional maitenance is required. Just let it run, occasionally checking that the date of the file is updated to reflect that month's database update.  
  
**Cron Job, Final Command Line string:**  

Code:

(directory-structure)/update-maxmind-database \>/dev/null 2\>&1

  
Best Wishes!  
  
CraigM

---

<div class="post-metadata">

### Author: ![CraigM](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@CraigM](https://forum.mautic.org/u/CraigM)
#### Post date: [April 11, 2016, 3:34pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199/2 "2016-04-11T15:34:56Z")

</div>

As a side note: After I installed MaxMinds’s GeoLite2-City database my campaign ran for the first time without any modification to the campaign.

I cannot explain it but the campaign ran.

CraigM

---

<div class="post-metadata">

### Author: ![CraigM](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@CraigM](https://forum.mautic.org/u/CraigM)
#### Post date: [April 10, 2016, 7:45pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199/3 "2016-04-10T19:45:36Z")

</div>

These are the step by step instructions I used to install MaxMinds’s GeoLite2-City database with monthly updates on Hostgator.

MxyzptlkFishStix deserves a big round of applause for his help!

How to Obtain and update MaxMinds’s GeoLite2-City database.

1. Go to [http://dev.maxmind.com/geoip/geoip2/geolite2/](http://dev.maxmind.com/geoip/geoip2/geolite2/) and download (to your pc) the “MaxMind DB binary, gzipped” version.

2. Extract the resulting file from GeoLite2-City.mmdb.gz to GeoLite2-City.mmdb using PKZip or other compression utility.

3. Copy (ftp) the file GeoLite2-City.mmdb to your server: (directory-structure)/public\_html/mautic/app/cache/ip\_data

Note: Modifying (directory-structure) to reflect your server’s directory structure. Your directory structure can be determined in your C Panel under “Account Information” or by using your C Panel’s File Manager. In File Manager at the top of the Directory tree (on the left) you will see a little house Icon. That is your (directory structure).

Note: I copied (ftp) the file to ensure that I was able to create the file in the ip\_data directory which should already be present under the current release of Mautic. If the ip\_data directory does not exist, create it.

Create the update-maxmind-database update file to be used monthly when updating the GeoLite2-City.mmdb

1. Create a blank update-maxmind-database.txt file in notepad and paste the following into it modifying (directory-structure) to reflect your server directory structure.

`#!/bin/bash
wget -N -P (directory-structure)/public_html/mautic/app/cache/ip_data http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
gunzip -f (directory-structure)/public_html/mautic/app/cache/ip_data/*.gz`

2. Save the file as update-maxmind-database.txt

3. Copy (ftp) the update-maxmind-database.txt to the (directory-structure) directory. In my case I put it in the root directory.

4. Rename your file (update-maxmind-database.txt) it removing the .txt to update-maxmind-database using the File Manager from your C Panel.

5. Change the file permissions to full read, write, execute permissions using the File Manager from your C Panel.

Create a new Cron Job from within your C Panel as follows:

1. Enter your Cron Jon Command string as follows:

```auto
(directory-structure)/update-maxmind-database
```

Note: Modify (directory-structure) to reflect your server directory structure.

2. Set Cron Job to run every 5 minutes.

3. Delete the database file: (directory-structure)/public\_html/mautic/app/cache/ip\_data/GeoLite2-City.mmdb.

4. Let the Cron job run.

5. Check the resulting Cron Job notification email to ensure that the database downloaded and extracted from .gz to .mmdb

6. Check that the database file was created: (directory-structure)/public\_html/mautic/app/cache/ip\_data/GeoLite2-City.mmdb.

Note: The database file may have the same creation date as the original you deleted. The file date will change monthly as new .mmdb files are created by MaxMind.

7. Add the suffix to the right end of the Cron Job to suppress error logs.

```auto
>/dev/null 2>&1
```

8.Change Cron Job to run sometime after the first Tuesday of each month. This is to reflect MaxMinds, database updates on the first Tuesday of each month.

Note: The current database in your file structure is overwritten each time the Cron Job runs. No additonal files are created and the .gz file is removed as well. Once the Cron Job is running no additional maitenance is required. Just let it run, occasionally checking that the date of the file is updated to reflect that month’s database update.

Cron Job, Final Command Line string:

```auto
(directory-structure)/update-maxmind-database >/dev/null 2>&1
```

Best Wishes!

CraigM

---

<div class="post-metadata">

### Author: ![OA\_Andrew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/oa_andrew/32/497_2.png) [@OA\_Andrew](https://forum.mautic.org/u/OA_Andrew)
#### Post date: [April 6, 2017, 8:12pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199/4 "2017-04-06T20:12:16Z")

</div>

Looks like the GeoLite database url has changed

---

<div class="post-metadata">

### Author: ![OA\_Andrew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/oa_andrew/32/497_2.png) [@OA\_Andrew](https://forum.mautic.org/u/OA_Andrew)
#### Post date: [April 6, 2017, 8:56pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199/5 "2017-04-06T20:56:27Z")

</div>

I found my wget script failing. Had to install the geoipupdate program for the County & City databases.

[http://dev.maxmind.com/geoip/geoipupdate/](http://example.com)

---

<div class="post-metadata">

### Author: ![JConnell](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/jconnell/32/159_2.png) [@JConnell](https://forum.mautic.org/u/JConnell)
#### Post date: [April 7, 2017, 2:21pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199/6 "2017-04-07T14:21:25Z")

</div>

There is a cron job for this now: `php /path/to/mautic/app/console mautic:iplookup:download`

---

<div class="post-metadata">

### Author: ![Yosu\_Cadilla](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/yosu_cadilla/32/6206_2.png) [@Yosu\_Cadilla](https://forum.mautic.org/u/Yosu_Cadilla)
#### Post date: [June 26, 2020, 9:23pm UTC](https://forum.mautic.org/t/solved-how-to-install-geolite2-city-ip-lookup-db/5199/7 "2020-06-26T21:23:53Z")

</div>

@JConnell If you use CraigM’s method, you’ll want to deactivate the `mautic:iplookup:download` after that as it will just mess your database.

Here’s a very detailed post I wrote about it including which cron job to use after patching your Mautic instance…

[https://mauteam.org/mautic/mautic-admins/solved-maxmind-geolite2-database-not-updating/](https://mauteam.org/mautic/mautic-admins/solved-maxmind-geolite2-database-not-updating/)
