GeoIP introduces to the way of establishing a computer terminal’s geographic location by recognizing that terminal’s IP address. Though GeoIP can pinpoint a terminal’s location in a city, it needs the use of a GeoIP database as strong as an understanding of APIs to achieve correctly.

Furthermore, GeoIP is not as reliable as other methods of geolocation, such as GPS and mobile technology, though no geolocation system passes complete accuracy. It is also possible for experienced users to cover or alter their apparent location from GeoIP systems.

Applications:

1) Involves geo-targeting or determining a computer’s location.
2) Most often used for targeted advertising, statistical research, spam prevention.
3) Also for restricting access based on location.

Installing GeoIP on PHP 7.X

To install this extension on PHP 7.0, 7.1, or 7.2, run the following commands as your server's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libgeoip-dev
sudo pecl7.X-sp install geoip-beta

Once installed, create a configuration file for the extension and restart PHP by running the following command as root:

sudo bash -c "echo extension=geoip.so > /etc/php7.X-sp/conf.d/geoip.ini"
sudo service php7.X-fpm-sp restart

Installing GeoIP on PHP 5.X

To install this extension on PHP 5.4, 5.5, or 5.6, run the following commands as your server's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libgeoip-dev
sudo pecl5.X-sp install geoip

Once installed, create a configuration file for the extension and restart PHP by running the following command as root:

sudo bash -c "echo extension=geoip.so > /etc/php5.X-sp/conf.d/geoip.ini"
sudo service php5.X-fpm-sp restart

Verifying GeoIP Is Installed

You can check that the extension was installed with this command:

phpX.Y-sp -i | grep geoip

The output will look like this:

$ php7.1-sp -i | grep geoip
/etc/php7.1-sp/conf.d/geoip.ini,
geoip
geoip support => enabled
geoip extension version => 1.1.1
geoip library version => 1006000
geoip.custom_directory => no value => no value

Uninstalling the GeoIP Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/geoip.ini
sudo peclX.Y-sp uninstall geoip

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart
Was this answer helpful? 0 Users Found This Useful (1 Votes)