Alternative to MaxMind: the free Abstract API serviceĪbstract provides a free geolocation service based on your visitors' IP address, which is very simple to use, does not require installation of any additional components aside from libcurl, and always remain up-to-date without you having to worry about it. Moreover, the MaxMind files being quite large, you may have a performance loss when several visitors are connected simultaneously on your server. Since such a database is updated regularly, you will have to download it again on your servers each time it is updated. $reader = new Reader('/path/to/GeoIP2-City.mmdb') Įcho($record->country->name) // 'United States'Įcho($record->city->name) // 'Mountain View'Įcho($record->location->latitude) // 37.4223Įcho($record->location->longitude) // -122.085ĭrawbacks of using MaxMind geolocation in PHPĭownloading the MaxMind database and installing its API are additional steps that may put off some of us. I want to set it up so that PHP code can call geoip information something like this.
I would like to install this on my Debian 6.0 64bit VPS running DirectAdmin. The easiest way to get the visitor's IP address is to use the REMOTE_ADDR entry, which returns the client's IP address requesting the current page. I searched the forums but didnt find anything much in regard to a custom php install of Maxminds PHP geoip. It contains information about the server and the HTTP connection, such as HTTP headers and the client's IP address. The PHP variable $_SERVER is an array whose entries are created by the webserver. The best geolocation tools will get you the following information: country, region, city, postal code, longitude, and latitude. But the new format also requires a different method of setup. This new format is supposed to be better/faster, etc.
Since then, Maxmind has updated their database format to GeoIP2.
If you manage to retrieve his IP address, you can obtain the device's location within a few kilometers. How To Install Maxmind PHP Extension on Your Server which detailed how to get the Maxmind’s GeoIP database setup on your server. The geolocation tool can query its database to returns details about the requested IP address's physical location. To get your visitors' physical location, you need two things: the IP address of your target, which you can obtain using a simple PHP script, and a geolocation search tool. IP-based geolocation is a way to physically locate a computer, a mobile, or any device connected to the Internet.