Installing Maxmind’s Geoipupdate on your Centos 7.x server is easy using an .rpm and some basic commands. Here’s the follow-up tutorial explaining how to automate copying MaxMind’s databases to your WordPress /wp-content/uploads folder so they can be used with custom functions or plugins.
Check Your Specs First
Before proceeding, check your server specs and adjust the following instructions appropriately.
Linux OS and Version
]# vi /etc/redhat-release
32 bit or 64 bit system
]# uname -m
32 bit = i686 or i386
64 bit = x86_64
Also make sure your user (root or something else) can execute commands, access the crontab, and can download and install rpms. Typically, root has all the necessary permissions.
Installing Geoipupdate from .rpm
Intended Audience: Novice – Intermediate Linux User
The following describes the process for Centos 7.9.x on a x86_64 machine. Adjust the following for your particular server and Geoipupdate package.
Visit the MaxMind Geoipupdate Github releases page. Find the latest package for your server.
x86_64 servers – Look for linux_amd64.rpm
At time of writing, I used: geoipupdate_4.8.0_linux_amd64.rpm
Login to your server using SSH. Go to the /tmp folder.
If you don’t have one, make one. It’s useful for downloading and unpacking files without disrupting your system.
]# cd /tmp
Suggestion: Remove any older Geoipupdate rpms in your /tmp folder before proceeding!
Next, use wget to fetch the rpm. Once complete, it will be inside your /tmp folder.
]# wget https://github.com/maxmind/geoipupdate/releases/download/v4.8.0/geoipupdate_4.8.0_linux_amd64.rpm
Unpack and install the rpm you just downloaded:
]# rpm -Uvhi geoipupdate_4.8.0_linux_amd64.rpm
A wildcard works assuming you took the suggestion:
]# rpm -Uvhi geoipupdate_4.8.*
The default Geoipupdate configuration file location is /etc/GeoIP.conf. Advanced users can change this location if they want.
Geoipupdate will store fresh database downloads in /usr/share/GeoIP. Again, advanced users can change this location.
Open /etc/GeoIP.conf with an editor like vim or nano.
]# vi /etc/GeoIP.conf
Next, login to your maxmind.com account. Click “Manage License Keys”.
Important: If you haven’t done so already, generate a new license key.
MaxMind will not retrieve an old or lost key. They only display the first few characters of your old key. You’ll have to generate a new one.
Open the following page to see a prefilled GeoIP.conf file with your account number and all available editions for download. Substitute “xxxxxx” with your account number.
Copy+paste the following into your server GeoIP.conf file:
AccountID – same as xxxxxx
LicenseKey – Use your existing or newly generated key
EditionIDs – Include all found in the prefilled file.
Suggestion: Only copy+paste the prefilled GeoIP.conf file to your server if you do not want to customize any other settings.
If you overwrite all the optional settings during copy+paste, you won’t be able to edit them later. Best to leave the optional settings intact and commented out for future edits.
Testing Geoipdate Installation
Run Geoipupdate in verbose mode to check for any errors or hiccups. If all goes well, you’ll find each Edition you specified above in #5 in the /usr/share/GeoIP folder.
]# geoipupdate -v
(Make sure that’s a small v, a large V will return the version number).
Configuring Geoipupdate Cronjob
Assuming your test run succeeded, now it’s time to automate Maxmind GeoIP database updates using a CronJob.
First, find the path to geoipupdate. Maxmind’s suggested Cronjob has geoipupdate in /usr/local/bin/.
CentOS 7.x users might find it somewhere else, like /usr/bin. Use “which” to find which one:
]# which geoipupdate
Open your crontab for editing.
]# crontab -e
Add the following Geoipupdate cronjob, adjusting day and time as you see fit. Make sure you use the path to Geoipupdate from your
]# which geoipupdate output.
23 1 * * 6,4 /usr/bin/geoipupdate
This runs geoipupdate at 1:23 AM on Thursday and Saturday. If manually entering the cronjob is too much, use a Crontab Generator for assistance.
That’s it, you’ll now get the databases twice weekly. Note, MaxMind only updates 1-2x weekly, so a daily download isn’t necessary.
See our companion tutorial for a helpful Bash script that will download MaxMind’s databases using Geoipupdate, then copy each database to your WordPress websites’ /wp-content/uploads folder. This makes them available to custom functions and plugins.
Avoiding Go Get for Now
Note: I’m not a fan of using Go to install Geoipupdate from from Maxmind’s Git source. A failed installation attempt using Go left me with a precarious uninstall process using
to remove files.
This StackOverflow question has some useful answers. One response suggested
]# go get [email protected]
worked in 2021. Unfortunately this didn’t work for me. Another reply recommended this Go answer.