简体   繁体   中英

Unable to locate package php8.1-geoip

I am upgrading a system from PHP 7.4 to 8.1 using as base Ubuntu 22.10.

In the old image, we are using php7.4-geoip , but this package doesn't exist in PHP 8.1.

apt install php8.1-geoip

Unable to locate package php8.1-geoip

What is the procedure to migrate to a newer version?

This package isn't available yet, however you can install via composer.

Ensure GeoIP is installed on the machine:

apt install -y geoip-bin geoip-database
geoipupdate -v

Install via PHP Composer:

curl -sS https://getcomposer.org/installer | php
php composer.phar require geoip2/geoip2:~2.0

Quick test script to ensure it's all working:

<?php

require_once 'vendor/autoload.php';

use GeoIp2\Database\Reader;

$geoip = new Reader('/usr/share/GeoIP/GeoLite2-City.mmdb');
$reader = $geoip->city('12.87.118.0');

echo "I should be United States.... ".$reader->country->name."\n";

Output:

root@cc19c55aedef:/# php test-geoip.php
I should be United States.... United States

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM