无法安装 Curl

无法安装 Curl

(请查看两个编辑)。Ubuntu 18.04,PHP 7.4.2。我需要帮助在我的服务器上安装 Curl PHP 包。这是我遇到的问题以及我迄今为止尝试过的方法:

当我运行时sudo apt-get install php-curl,遇到以下错误:

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:
 php-curl : Depends: php7.4-curl but it is not going to be installed

我跟着这些步骤识别并移除破损的包裹,尝试纠正前半部分。

当我运行时sudo apt-get install php7.4-curl出现此错误:

The following packages have unmet dependencies:
 php7.4-curl : Depends: libcurl4 (>= 7.56.1) but it is not going to be installed

所以我尝试了一下sudo apt-get install libcurl4,并得到了这个:

The following additional packages will be installed:
  php7.4-fpm
The following packages will be REMOVED:
  apache2 apache2-bin libapache2-mod-php libapache2-mod-php7.0
  libapache2-mod-php7.4 libcurl3 python-certbot-apache python3-certbot-apache
The following NEW packages will be installed:
  libcurl4 php7.4-fpm
0 upgraded, 2 newly installed, 8 to remove and 0 not upgraded.
Remv python-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1]
Remv python3-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1]
Remv apache2 [2.4.41-1+ubuntu16.04.1+deb.sury.org+5]
Remv libapache2-mod-php [2:7.4+75+ubuntu18.04.1+deb.sury.org+1]
Inst php7.4-fpm (7.4.4-1+ubuntu18.04.1+deb.sury.org+1 ***** The main PPA for supported PHP versions with many PECL extensions *****:18.04/bionic [amd64])
Remv libapache2-mod-php7.4 [7.4.4-1+ubuntu18.04.1+deb.sury.org+1]
Remv libapache2-mod-php7.0 [7.0.33-26+ubuntu18.04.1+deb.sury.org+1]
Remv apache2-bin [2.4.41-1+ubuntu16.04.1+deb.sury.org+5]
Remv libcurl3 [7.58.0-2ubuntu2]
Inst libcurl4 (7.58.0-2ubuntu3.8 Ubuntu:18.04/bionic-security [amd64])
Conf php7.4-fpm (7.4.4-1+ubuntu18.04.1+deb.sury.org+1 ***** The main PPA for supported PHP versions with many PECL extensions *****:18.04/bionic [amd64])
Conf libcurl4 (7.58.0-2ubuntu3.8 Ubuntu:18.04/bionic-security [amd64])

我不明白它为什么要删除 apache2、certbot 和其他各种重要软件包。有人能建议如何在不删除那么多其他软件包的情况下安装 Curl 吗?


编辑:

我跟着本指南删除与 PHP 相关的所有内容,然后安装 PHP7.2(建议:18.04 附带的版本)。PHP -v现在返回PHP 7.2.29-1+ubuntu18.04.1+deb.sury.org+1。但是,我仍然遇到相同的问题。在建议尝试使用 aptitude 安装后,错误消息更详细一些:

    The following NEW packages will be installed:
  libcurl4{ab} php7.4-common{a} php7.4-curl
The following packages will be REMOVED:
  libonig4{u} libpcre2-8-0{u}
0 packages upgraded, 3 newly installed, 2 to remove and 0 not upgraded.
Need to get 245 kB/1,243 kB of archives. After unpacking 7,098 kB will be used.
The following packages have unmet dependencies:
 libcurl3 : Conflicts: libcurl4 but 7.58.0-2ubuntu3.8 is to be installed
 libcurl4 : Conflicts: libcurl3 but 7.58.0-2ubuntu2 is installed
The following actions will resolve these dependencies:

     Remove the following packages:
1)     apache2 [2.4.41-1+ubuntu16.04.1+deb.sury.org+5 (now)]
2)     apache2-bin [2.4.41-1+ubuntu16.04.1+deb.sury.org+5 (now)]
3)     libapache2-mod-php7.2 [7.2.29-1+ubuntu18.04.1+deb.sury.org+1 (bionic, now
4)     libcurl3 [7.58.0-2ubuntu2 (bionic, now)]
5)     python-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1 (bionic, now)]
6)     python3-certbot-apache [0.31.0-1+ubuntu18.04.1+certbot+1 (bionic, now)]

这些信息是否表明为什么在安装 curl/libcurl 之前要删除 apache2 和列表中的其他模块?


编辑2:

经过多次尝试和挫折(和绝望)后,我尝试了以下方法,按照线:

sudo add-apt-repository main
sudo add-apt-repository universe
sudo add-apt-repository restricted
sudo add-apt-repository multiverse
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php-curl

前四个存储库命令的输出是component is already enabled for all sources.ppa:ondrej/php 已添加,ondrej/apache2 也是如此。我运行了好sudo apt-get update几次。

但是,不知何故,按照顺序执行这些操作解决了任何问题,现在我的服务器上的 cURL 可以正常运行。

答案1

您正在使用额外的存储库称为 PPA(个人软件包存档)。如前所述这里

PPA 中的软件包不经过与主存储库中的软件包相同的验证过程。

这意味着依赖关系不一定适用于所有基础系统(并且还具有安全隐患):

PPA 是主存储库的低安全性替代品,因此用户安装软件时需自行承担风险。

相关内容