Ubuntu安装pecl_http失败。

18

我正在尝试安装这个扩展,但在配置阶段失败了。我使用的是ubuntu 12.04,刚刚安装了以下软件包:

  • libcurl3-openssl-dev
  • php-http
  • libpcre3-dev
  • libcurl3
  • php-pear
  • php5-dev

PHP版本:

PHP 5.3.10-1ubuntu3.14 with Suhosin-Patch (cli) (built: Sep  4 2014 07:08:49) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

这里是安装命令的日志:

sudo pecl install pecl_http
downloading pecl_http-2.1.1.tgz ...
Starting to download pecl_http-2.1.1.tgz (158,441 bytes)
.................................done: 158,441 bytes
64 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
Enable extended HTTP support [yes] : 
where to find zlib [/usr] : 
where to find libcurl [/usr] : 
where to find libevent [/usr] : 
building in /tmp/pear/temp/pear-build-rootqE2kgU/pecl_http-2.1.1
running: /tmp/pear/temp/pecl_http/configure --with-http --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/home/gare88/Lib/Php/libevent-2.0.21-stable/
checking for grep that handles long lines and -e... /bin/grep

[... cut...]

checking for zlib.h... found in /usr
checking for zlib version >= 1.2.0.4... 1.2.3.4
checking for curl/curl.h... found in /usr
checking for curl-config... found: /usr/bin/curl-config
checking for curl version >= 7.18.2... 7.22.0
checking for SSL support in libcurl... yes
checking for openssl support in libcurl... no
checking for gnutls support in libcurl... no
checking for ares support in libcurl... no
checking for bundled SSL CA info... /etc/ssl/certs/ca-certificates.crt
checking for event2/event.h... not found
configure: WARNING: continuing without libevent support
checking for ext/raphf support... no
configure: error: Please install pecl/raphf and activate extension=raphf.so in your php.ini
ERROR: `/tmp/pear/temp/pecl_http/configure --with-http --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/usr' failed

看起来是与 pecl/raphf 有问题,因此我尝试了:

sudo pecl install raphf
pecl/raphf is already installed and is the same as the released version 1.0.4
install failed

我在位于 /etc/php5/apache2/php.ini 的文件末尾添加了以下行:

extension=raphf.so
extension=propro.so
extension=http.so

还有什么其他方法我可以尝试吗?


这个与PHP相关的bug可以在此链接中找到:https://bugs.php.net/bug.php?id=67622。看起来它还没有被修复。 - Synchro
6个回答

12

您需要从软件包管理器安装 php-raphf。

我使用以下方式安装了该模块。在您的情况下,您应该可以将 yum 替换为 apt-get。

sudo yum install php-raphf
sudo yum install php-propro
sudo pecl install pecl_http

您需要在php.ini文件中添加extension = http.so。但看起来您已经完成了这个步骤。

pecl实际上不会安装您要查找的.so文件。


1
好的,看起来问题是缺少.so文件(我尝试了查找但没有结果)。我将下载它。谢谢。 - GareDeveloper
太棒了,很高兴看起来它对你有用,请告诉我如果你在安装过程中需要更改任何内容,这样我就可以为其他人更新答案 :) - michael.schuett
1
Ubuntu在标准仓库中没有raphf或propro扩展,至少在Precise版本中是这样。我已经从PECL安装了它们,.so文件已经就位,并且PHP在php -m输出中显示它们,但是pecl_http仍然无法像之前一样安装。 - Synchro
没有可用的php-raphf软件包。 - Muaaz Khalid

8

如果您使用的是Ubuntu 13或14版本,请尝试使用pecl install pecl_http-1.7.6安装,因为较新的版本由于某些原因仍无法加载。


你确定它没有被加载,还是因为版本2.x中删除了版本1提供的每个类/函数而导致未加载。版本2的文档可以在此处找到:https://mdref.m6w6.name/http - David
@David 我确定它没有出现在几个不同的Linux发行版中加载的PHP扩展中。 - coviex

7
在Ubuntu 12.04.5 LTS上,我成功运行了以下步骤:
第一步,安装编译所需的一些先决条件:
sudo apt-get install php-http
sudo apt-get install php5-dev
sudo apt-get install libcurl3
sudo apt-get install libpcre3-dev
sudo apt-get install libcurl4-openssl-dev
sudo pecl install raphf 
sudo pecl install pecl_http-1.7.6

接下来进入文件夹/usr/lib/php5/modules,检查是否有以下库:raphf.sopropro.sohttp.so

如果你的php.ini(位于/etc/php5/apache2/php.ini/etc/php5/cli/php.ini)中没有这些扩展,就添加它们:

extension=http.so
extension=propro.so
extension=raphf.so

或者使用文件的绝对路径,例如 extension=/usr/lib/php5/modules/http.so

最后一步是重新启动您的Web服务器,以加载新的配置:

sudo service apache2 reload

文档说明应该在php.ini文件中将propro.so和raphf.so放在http.so之上。 - Chris
罪魁祸首是 php-dev。请使用 sudo apt-get install php-dev 确保安装了与从命令行运行 php 时调用的相同 php 版本的开发工具。 - Marco Marsala
在Ubuntu 18.04上尝试过了。尝试了所有这些后,我发现zlib出现了错误,并且发现我缺少了dev包。我安装了它,然后pecl_http成功完成了。 apt-get install zlib1g-dev - G_Style

5

补充一下@mschuett的回答,当我遇到与OP相同的错误时,我发现在php.ini中更改我的扩展引用可以解决问题。

extension=raphf.so

为了

extension=/usr/lib/php5/20121212/raphf.so

那么

sudo pecl install pecl_http

同时设置以下内容,可以避免在 PECL 安装需要修改 php.ini 文件时手动编辑:
pear config-set php_ini /etc/php5/apache2/php.ini
pecl config-set php_ini /etc/php5/apache2/php.ini

注意:此方法适用于Ubuntu 14.04 LTS。


0

我在尝试在Ubuntu 16.04和php-fpm5.6上安装pecl_http-2.6.0、raphf-1.1.2和propro-1.0.2时遇到了问题。我无法使用apt安装raphf和propro(正如@mschuett建议的那样),因为apt只能安装适用于PHP 7的raphf 2.0.0和propro 2.1.0。

我通过以下步骤解决了这个问题,而不需要更新php.ini或使用apt

首先,要让php-fpm加载新扩展,必须将一个.ini文件添加到/etc/php/5.6/mods-available中。然后使用phpenmod启用该扩展。

因此,要安装并启用raphf-1.1.2,

$ pecl install raphf-1.1.2
$ echo "extension=raphf.so" >> /etc/php/5.6/mods-available
$ phpenmod raphf

请注意,这些命令可能需要使用sudo
同样地,在propro-1.0.2中。
$ pecl install raphf-1.0.2
$ echo "extension=raphf.so" >> /etc/php/5.6/mods-available
$ phpenmod raphf

如果您使用php -m命令查看所有已加载的扩展,您应该能够在列表中看到raphf和propro。

现在,您可以使用以下命令安装pecl_http-2.6.0:

$ pecl install pecl_http-2.6.0

安装应该成功完成。

$ pecl list
Installed packages, channel pecl.php.net:
=========================================
Package   Version State
pecl_http 2.6.0   stable
propro    1.0.2   stable
raphf     1.1.2   stable

如果你像我一样使用pecl,你可能会看到警告信息,比如:
install ok: channel://pecl.php.net/pecl_http-2.6.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=http.so" to php.ini

这是因为我的pearpeclphp_ini配置没有设置。


0

运行命令

  1. sudo yum install php-raphf

    • sudo yum install php-propro
  2. sudo pecl install pecl_http

  3. etc/phph5/apache2/conf.d

添加两个文件

  • raphf.ini

添加内容

extension=raphf.so

solr.ini

添加内容

extension=raphf.so

在php.ini文件中加入以下内容

extension=http.so extension=propro.so extension=raphf.so 或者 extension=/usr/lib/php5/20121212/raphf.so extension=solr.so


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接