我已经使用这个repo安装了PHP 7,但是当我尝试运行composer install时,它给出了这个错误:

[package] require ext-curl * ->系统中缺少所请求的PHP扩展curl。

使用PHP 5,您可以通过运行yum或apt-get install php5-curl命令轻松安装它,但我找不到如何安装PHP 7的等效程序。

如何为PHP 7安装ext-curl ?


当前回答

如果你有404或错误,而sudo apt-get安装php-curl只是尝试

sudo apt-get update

再试一次

sudo apt-get install php-curl

但请注意安装的版本(我使用php7.3和php7.4-curl安装-所以它将无法工作)

然后试着

sudo apt-get install php7.3-curl

最后,你可能想重新启动服务,如:apache2或php-fpm:

sudo apache2 restart
sudo service php7.3-fpm restart

这对我很管用。

检查curl是否在当前php的已安装模块列表中:

php -m

其他回答

如果你正在使用PHP7.1(尝试php -version找到你的php版本)

sudo apt-get install php7.1-curl

然后重新启动apache

sudo service apache2 restart

首先登录到你的服务器,检查你的服务器上安装的PHP版本。

然后执行如下命令:

sudo apt-get install php7.2-curl

sudo service apache2 restart

将PHP版本(php7.2)替换为您的PHP版本。

sudo apt-get install php7.0-curl

我们可以安装任何PHP7扩展,我们需要在安装Magento时,只需使用相关的命令,你会在安装Magento时得到错误

sudo apt-get install php7.0-curl
sudo apt-get install php7.0-dom
sudo apt-get install php7.0-mcrypt
sudo apt-get install php7.0-simplexml
sudo apt-get install php7.0-spl
sudo apt-get install php7.0-xsl
sudo apt-get install php7.0-intl
sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-ctype
sudo apt-get install php7.0-hash
sudo apt-get install php7.0-openssl
sudo apt-get install php7.0-zip
sudo apt-get install php7.0-xmlwriter
sudo apt-get install php7.0-gd
sudo apt-get install php7.0-iconv

好吧,我可以安装它:

sudo apt-get install php-curl

在我的系统上。这将安装一个依赖包,依赖于默认的php版本。

然后重启apache

sudo service apache2 restart