GeoIP is a PHP extension, which is used to get all the information like, city, state, country, longitude / latitude etc for any IP address. You can use this extension to track the visitors to your site. It can help you prepare better analytic for your user-base with the information collected.
To install GeoIP, we require the GeoIP C library version 1.4.0 or higher. If you are using ubuntu or Debian, simply run the following command :
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
sudo mkdir -v /usr/share/GeoIP
sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
sudo apt-get install php5-geoip
To get the data for any IP or domain, you can use the following PHP functions :
var_dump(geoip_record_by_name($_SERVER['REMOTE_ADDR']));
var_dump(geoip_record_by_name('www.domain-name.com'));