I realize at this point this question is about 4+ years old, but I wanted to add additional details on how users of more current versions of Mac OS X—like Mac OS X 10.7 (Lion), Mac OS X 10.8 (Mountain Lion) and Mac OS X 10.9 (Mavericks)—can install GeoIP on their machines. This has been tested by me up until Mac OS X 10.9.5, but I believe the exact same instructions should work well for Mac OS X 10.10 (Yosemite).
As far as Python/Django integration goes, I am fairly sure that if the GeoIP binary—and related databases—are properly installed systemwide, you don’t have to futz with GEOIP_PATH or related settings. But would be open to hearing from others in the comments if my assumption is wrong.
Prerequisites.
First, one needs to have Xcode installed. And since Xcode—since at least version 4.3 I believe—no longer includes the GNU versions of autoconf, automake and libtool those need to be installed as well. I provide details on how to install autoconf, automake and libtool in this answer. The rest of this answer assumes your system already has that setup.
Installing GeoIP from source.
With the prerequisites covered, you can install MaxMind’s GeoIP as follows.
Set the working directory to your home directory:
cd
Get the source code and decompress it:
curl -O http://www.maxmind.com/download/geoip/api/c/GeoIP-latest.tar.gz
tar -xvzf GeoIP-latest.tar.gz
Go into the uncompressed source code directory:
cd ./GeoIP*
Run libtoolize on the source code:
libtoolize -f
When that is done, run the configure script on the source code:
./configure
Now run make to compile it:
make
Then run make check to check all is good:
make check
Now install it:
sudo make install
Check it’s installed by running the geoiplookup command whose output should be something like this:
Usage: geoiplookup [-h] [-?] [-d custom_dir] [-f custom_file] [-v] [-i] [-l] <ipaddress|hostname>
Now you have the GeoIP source code compiled, but you don’t have any GeoIP databases installed for it to to use/reference. So let’s install them.
Installing GeoIP databases.
So we’re going to get the three (3) major GeoIP databases that are available out there with curl like this. Set the working directory to your home directory:
cd
And now use curl to get the GeoIP.dat.gz, GeoLiteCity.dat.gz and GeoIPASNum.dat.gz databases:
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
curl -O http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
With that done, let’s move them into the proper directory for the GeoIP program to reference them which is /usr/local/share/GeoIP/. If that directory doesn’t exist on your system, you can make it like this:
sudo mkdir -p /usr/local/share/GeoIP/
Now with that done, move the downloaded GeoIP.dat.gz, GeoLiteCity.dat.gz and GeoIPASNum.dat.gz databases into that directory:
sudo mv ~/GeoIP.dat.gz /usr/local/share/GeoIP/
sudo mv ~/GeoLiteCity.dat.gz /usr/local/share/GeoIP/
sudo mv ~/GeoIPASNum.dat.gz /usr/local/share/GeoIP/
And decompress them in place:
sudo gzip -d -f /usr/local/share/GeoIP/GeoIP.dat.gz
sudo gzip -d -f /usr/local/share/GeoIP/GeoLiteCity.dat.gz
sudo gzip -d -f /usr/local/share/GeoIP/GeoIPASNum.dat.gz
We also need to rename GeoLiteCity.dat to GeoIPCity.dat like this:
sudo mv /usr/local/share/GeoIP/GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat
Final GeoIP binary testing.
With the GeoIP binary compiled from source and installed as well as having the databases in place, geoiplookup should work as expected. For example, let’s do a GeoIP lookup on Google:
geoiplookup google.com
The output of that command if all went well should be:
GeoIP Country Edition: US, United States
GeoIP City Edition, Rev 1: US, CA, California, Mountain View, 94043, 37.419201, -122.057404, 807, 650
GeoIP ASNum Edition: AS15169 Google Inc.