Main > Abyss | Linux | PHP > PHP 8.1 and GeoIP package is missing, has been obsoleted, or is only available from another source

PHP 8.1 and GeoIP package is missing, has been obsoleted, or is only available from another source

21.04.2024 0 comments » Views: 4

Geo IP

Today I updated one of my old project from PHP 7.1 to PHP 8.1. After this upgrade I faced with a problem in GeoIP module usage as it was not available OOTB as a part of PHP installation..

When I tried to install it like the next I saw an error

This happened because the module was obsolete and was removed.

I fixed this as follow.

First of all I installed GeoIP package and utility to updated GeoIp databases

Then, if you trigger the update you will see next error

To resolve it, you need to go to MaxMind website and create free account, then you need to generate this file. Manual for this operation can be found here
- https://dev.maxmind.com/geoip/geolite2-free-geolocation-data

After you register you account you should generate new license key.

After license created the system will give you link to download GeoIP.conf file with the contents like

You need to put this into file on your server

After this will be done, you need to update the database as

After this you can see the GeoIp database

Then you can use this databases as described in the project GitHub
- https://github.com/maxmind/geoip-api-php

You need to install composer package

and then you can use the installed database as follow

Actually, that's all what is needed to fix the legacy code. If you need to use GeoIP with your new project it makes sense to use the newer implementation - GeoIP2, see details here

  • https://dev.maxmind.com/geoip/docs/databases?lang=en
  • https://dev.maxmind.com/geoip/geolite2-free-geolocation-data
  • https://github.com/maxmind/GeoIP2-php

Author: | Rating: 4/5 | Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Allowed HTML-tags: <a>, <code>, <i>, <em>, <strong>, <b>, <u>, <strike>