31

从今天的 16.04 升级到 18.04do-release-upgrade -d

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

删除: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.

我该如何纠正这种情况?

4

4 回答 4

78

这可以为您节省:

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

于 2018-05-08T21:09:11.943 回答
3

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

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
于 2018-08-19T01:14:09.680 回答
0

安装 libcurl4 对我有用

apt install libcurl4

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

于 2019-06-07T22:52:03.560 回答
-1

你必须以成熟的方式应对。安装 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

此方法不仅针对此错误您可以使用 aptitude 找到任何 php apache2 或 ubuntu 系统包解决方案。

Upvote if you find your solution
于 2021-10-09T20:38:35.373 回答