Installing MaxMind’s GeoIP on Debian / Ubuntu is too easy.

sudo apt-get install php5-geoip sudo /etc/init.d/apache2 restart

This installs the database to /usr/share/GeoIP/GeoIP.dat. You can now test it via  a simple PHP script like

Or use a bit more complex script like the following which first looks up the current IP address of the user and then checks in which country he is.