How to enable the PHP GeoIP functions on Debian 5
Posted August 13th, 2009 in Linux/Unix/BSD and PHP
The geoip_* PHP functions utilise the GeoIP library from Maxmind to geolocate IP addresses to country names. These functions are not enabled by default and this post shows how to enable them for PHP 5 on Debian 5.
Enable GeoIP for PHP 5 on Debian 5
Run the following command as the root user or using the sudo command. These instructions should also work on any Debian derived Linux distro such as Ubuntu.
apt-get install php5-geoip
You'll then see something along the lines of this:
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: php5-geoip 0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded. Need to get 0B/10.4kB of archives. After this operation, 41.0kB of additional disk space will be used. Selecting previously deselected package php5-geoip. (Reading database ... 50967 files and directories currently installed.) Unpacking php5-geoip (from .../php5-geoip_1.0.3-1_i386.deb) ... Setting up php5-geoip (1.0.3-1) ...
At this stage the GeoIP library is now installed but you'll still need to restart Apache to enable the extension when running scripts via the web server. This is done like so, again running the command as either the root user or using sudo:
/usr/sbin/apache2ctl graceful
My next post looks at how to use the GeoIP functions to look up a country code or name from an IP address.
Related posts:
- How to update the GeoIP.dat file on Debian 5 (Sunday, August 16th 2009)
- PHP geo targeting with the geoip functions (Thursday, August 13th 2009)
Share or Bookmark
Share or Bookmark this page using the following services. You will need to have an account with the selected service in order to post links or bookmark this page.
Subscribe or Follow
Subscribe via RSS or email, or follow me on Facebook or Twitter below. The RSS icon takes you through to Feedburner where you can select the service or application to use.
