PHP5-curl安装报错没有安装候选

PHP5-Curl install error no installation candidate

我想在我的 Debian 服务器上安装 PHP5-Curl。但是当我 运行 这个命令时:

apt-get install PHP5-Curl

我收到如下错误:

Reading package lists... Done
Building dependency tree
Reading state information... Done

Package PHP5-Curl is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'PHP5-Curl' has no installation candidate

您似乎安装了多个相互冲突的 PHP 版本。首先,让我们清理一下。首先备份您的配置文件,因为这将删除它们。

dpkg --purge --force-all php5-curl
apt-get remove php5-*
apt-get purge php5-*
apt-get autoremove

现在,再次 运行 dpkg -l | grep php5,确保没有安装 php5-... 包。

那么,让我们重新开始吧:

apt-get install php5-cli php5-curl

如果您需要 Apache 模块:

apt-get install libapache2-mod-php5

或者如果您需要 FPM 模块:

apt-get install php5-fpm

使用sudo apt-get install php5.6-curl

尝试使用 sudo apt-cache search curl | grep php 搜索适合您的可用版本,然后 sudo apt-get install php<x>-curl

在我的例子中是 php7.0-curl

首先使用命令 php -v 搜索您的 php 版本,然后下载相应版本的 php(version)-curl.