Mac OS X 10.3.4 is required will all relevant updates installed
Developers’ Tools are, as always, required for this tutorial
A version of Apache 1.3.x with APXS enabled is also necessary. (several PHPmac tutorials available)
Apache 2 version of mod_geoip is available, however, the method of installing this is outside the scope of this tutorial.

Step 1: Installing MaxMind GeoIP APIThe first step of this tutorial is a fairly straight foward build of the GeoIP API. The source is available free under the GPL

Once this has completed you need to add the following lines to the end of your Apache httpd.conf file.

<IfModule mod_geoip.c>
# If GeoIP is turned on, turn it on
GeoIPEnable On
</IfModule>

The paths to the conf file is usually /etc/httpd/httpd.conf. Explaining how to change your httpd.conf file is not within the scope of this tutorial.
Restart Apache:

sudo apachectl restart

Step 3: Using in your PHP web applicationsProbably the easiest part of the entire process is using this in everyday use. Basically, the module provides the country information, all the hard work is done by the module itself. To access the country information in PHP you can use the following script.

That’s it – all done. You can now call on this in all your PHP scripts. This is very effective method of automatically selecting Download Mirrors, providing location specific content, etc. for your visitors.

A word of warning: this method of determining geographical location can sometimes yield incorrect results. For example, if a multinational company has recently expanded to a new country and has taken IP addresses with it. This happened to me and I kept getting British mirrors on some websites when I wanted Irish ones. The moral of the story is to use this to make an initial “guess” – but always provide your users with a way to manually switch countries.

I have also written a little script that plots the location that GeoIP gives to a map of the world. It also checks the IP against the RIPE IP whois, or ARIN for US IPs. You can download the source here Requires GD and GeoIP (obviously)!

If you have any problems don’t hesitate to contact the support team. Click Here. A login is required.