Mautic Community Forums

Solved: How to Install GeoLite2-City IP Lookup DB

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/ 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

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

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/ 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:

(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.

>/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:

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

Best Wishes!

CraigM

Looks like the GeoLite database url has changed

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

http://dev.maxmind.com/geoip/geoipupdate/

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