Geolocalisation PHP

Aujourd’hui, au hasard du Web je suis tombé sur un outil qui permet de faire de la Géolocalisation en PHP grâce a Apache.

J’ai essayé cette méthode qui semble fonctionner. Il faut toutefois faire ses tests sur une machine en dehors du réseaux (une machine distante quoi).

Dans un premier temps, installer le module Apache qui va bien:

  • # apt-get install libapache2-mod-geoip

Rajoutez ceci au VirtualHost concerné par ce module:

<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
</IfModule>

Redémarrez Apache:

  • # /etc/init.d/apache2 restart

Dans une nouvelle page PHP ajoutez ceci:

<html>
<body>
<?php
$country_name = apache_note("GEOIP_COUNTRY_NAME");
print "Country: " . $country_name;
?>
</body>
</html>

Et voila, rendez-vous sur la page et admirez :)
Share !
  1. It’s rare for me to find something on the net that’s as entertaining and intriguing as what you’ve got here. Your page is lovely, your graphics are outstanding, and what’s more, you use reference that are relevant to what you are saying. You’re certainly one in a million, keep up the good work!

  1. No trackbacks yet.