如何在 Ubuntu 16.04 中安装 php-curl

How to install php-curl in Ubuntu 16.04

已升级到 Ubuntu 16.04,安装 PHP5 后遇到问题。

安装 PHP-5 具有以下内容:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5.5   # for PHP 5.5

正在尝试安装 php-curl 但它不起作用。

sudo apt-get install php5-curl

Error: E: Unable to locate package php5-curl

这对我有用:

sudo apt-get install php5.6-curl

在Ubuntu 16.04默认PHP版本是7.0,如果要使用不同的版本则需要根据[=37安装PHP包=]版本:

  • PHP 7.4: sudo apt-get install php7.4-curl
  • PHP 7.3: sudo apt-get install php7.3-curl
  • PHP 7.2: sudo apt-get install php7.2-curl
  • PHP 7.1: sudo apt-get install php7.1-curl
  • PHP 7.0: sudo apt-get install php7.0-curl
  • PHP 5.6: sudo apt-get install php5.6-curl
  • PHP 5.5: sudo apt-get install php5.5-curl

这对我有用。

sudo apt-get install php-curl

在 Ubuntu 16.04 和衍生版本

上安装 cURL 7.49.0
wget http://curl.haxx.se/download/curl-7.49.0.tar.gz
tar -xvf curl-7.49.0.tar.gz
cd curl-7.49.0/
./configure
make
sudo make install

做:

apt-get update

然后:

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

并重新启动网络浏览器。

您可以通过运行php -m | grep curl

查看模块

对于 Ubuntu 18.04 或 PHP 7.2 用户,您可以执行以下操作:

apt-get install php7.2-curl

您可以通过 运行 php -v 检查您的 PHP 版本以验证您的 PHP 版本并获得正确的 curl 版本。

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php8.0-curl