Ubuntu18.04升级后php7.2-curl无法安装

After Ubuntu 18.04 upgrade php7.2-curl cannot be installed

今天使用 do-release-upgrade -d

从 16.04 升级到 18.04

在升级过程中,我被告知将删除一些软件包,其中包括:

Remove: libperl5.22 lxc-common perl-modules-5.22 php-imagick
php7.1-curl php7.2-curl python3-certbot-nginx

我可以毫无问题地重新安装 imagick 和 certbot,但是如果我尝试安装 php7.2-curl,我会收到消息:

# apt install php7.2-curl -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php7.2-curl : Depends: php7.2-common (= 7.2.3-1ubuntu1) but 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.

我该如何纠正这种情况?

这可以为您节省:

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2-fpm php7.2-gd php7.2-curl php7.2-mysql php7.2-dev php7.2-cli php7.2-common php7.2-mbstring php7.2-intl php7.2-zip php7.2-bcmath

然后sudo service apache2 restart

您不需要添加新的存储库。只需执行此操作即可安装 7.2 版本。记得重启 php 和 apache 之后。还要确保(你可能已经这样做了)在

之后启用新的 mod
sudo apt install php-curl
sudo a2enmod php7.2

您可能还会注意到,在 php-curl(安装 php-curlphp7.2-curl)安装结束时,以下内容(请注意,我有 FPM 设置,可能如果你不使用 FPM,看起来会有所不同):

NOTICE: Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.

所以照它说的去做:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.2-fpm
sudo systemctl restart apache2.service

安装 libcurl4 对我有用

apt install libcurl4

然后安装 php7.2-curl,重新启动 apache2 没有问题。

你必须以成熟的方式去应对。安装 aptitude 这些 ubuntu 包管理器会找到所有依赖项,并会一一安装。

apt-get install aptitude

现在你必须检查 aptitude 是否可以下载它,如果按照说明下载它

sudo aptitude install php7.2-curl

如果您遇到这样的错误

E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'

任何类型的错误我不是在谈论正确的这些错误

再次尝试添加 php 包

sudo apt-add-repository ppa:ondrej/php

sudo apt-get update

现在试试这个命令

sudo aptitude install php7.2-curl

Aptitude 会询问您要保留所有依赖项的当前版本

The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     php7.2-curl [Not Installed]                        



Accept this solution? [Y/n/q/?]

输入 n 然后 Enter

Aptitude 将找到所有依赖项并要求您安装所有包类型

y

再次

y

然后

systemctl restart apache2

对于 rhel 的 centos

systemctl restart httpd

默认情况下不会启用 PHP 7.2 FPM。 注意:要在 Apache2 中启用 PHP 7.2 FPM,请执行

a2enmod proxy_fcgi setenvif

a2enconf php7.2-fpm

此方法不仅针对此错误您还可以找到任何php apache2 或ubuntu system package using aptitude 解决方案。

Upvote if you find your solution