Recently, I wrote about geolocalisation of your users/visitors based on the IP to Country table. After using it for a couple of months, I found it painful to have to regularly update the table (even if some people came up with an automatic work around based on PERL scripts for example).

So, I decided to find another way to solve the problem and gave the GeoIP Apache module by MaxMind a try. The installation is as simple as can be:

1
2
3
aptitude install libapache2-mod-geoip
a2enmod geoip
/etc/init.d/apache2 restart

Once the module is setup, you can use the following PHP code to obtain the Country Code (2 letters)

1
$countryCode == $_SERVER["GEOIP_COUNTRY_CODE"];

Finally, here is a list of country codes and the associated country names.

If yo

That’s it, quick and simple.

Filed under: PHP

Tagged with: , ,

Liked this page?

Tweet it

Subscribe to the RSS feed or sign up for the newsletter now.

Posts related to Where are your users from, part 2

1 Comment to "Where are your users from, part 2"

  1. Trackback on samantha on February 22, 2010 at 5:54 pm

    New blog post: Where are your users from, part 2:
    Recently, I wrote about geolocalisation of your users/visitors … http://bit.ly/9um21T

Name (required)

Email (required)

Website

Leave a Reply

  • About Me


    photo of Samantha Halfon Samantha Halfon
    Software Engineer
    blueKiwi software
    Paris, France
    I enjoy playing with my computer(s), listening to Bob Dylan (and related artists) and watching movies (especially if they were directed by Martin Scorsese or John Cassavetes). Sometimes, I play a little guitar... If not doing any of the above, I am either riding a small red bike around Paris, or, making videos. About my videomaking please check out World Wide Angle and its blog.