pecl_http configure: error: please install and enable pecl/raphf


作者: 我不是鱼 (2017-06-20 21:16) 分类: PHP   标签: pecl pecl_http

本文是在 PHP 7.1 下用 pecl 安装 HTTP 3.1,关于 HTTP 都有哪些具体功能请参考:
https://mdref.m6w6.name/http

我这里主要是想用其中解析cookie的一些函数。

[root@lnmp lnmp.cn]# pecl install pecl_http

中途有几个提示输入库路径的,默认留空回车就是。

然而安装并不成功,具体错误如下:

checking whether ext/raphf is enabled... no
configure: error: please install and enable pecl/raphf
ERROR: `/tmp/pear/temp/pecl_http/configure --with-php-config=/usr/local/php7/bin/php-config --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/usr --with-http-libicu-dir=/usr --with-http-libidn2-dir=/usr --with-http-libidn-dir=/usr --with-http-libidnkit2-dir=/usr --with-http-libidnkit-dir=/usr' failed
configuration option "php_ini" is not set to php.ini location
You should add "extension=raphf.so" to php.ini
configuration option "php_ini" is not set to php.ini location
You should add "extension=raphf.so" to php.ini
configuration option "php_ini" is not set to php.ini location
You should add "extension=propro.so" to php.ini

根据错误提示,要安装和 enable pecl/raphf,那如何去安装和 enable 呢?其实安装 http 的过程中, raphf 已经先被安装,至于 enable,输出信息里边有提示到:

configuration option "php_ini" is not set to php.ini location
You should add "extension=raphf.so" to php.ini
configuration option "php_ini" is not set to php.ini location
You should add "extension=propro.so" to php.ini

可以看到 raphf 和 propro 其实都已经安装好了,但 pecl 没能将他们加入到 php.ini 中,这是为什么呢?是由于这个引起:

configuration option "php_ini" is not set to php.ini location

因为 pecl 的 php_ini 配置项没有设置,所以导致 pecl 并不知道 php.ini 的位置。

[root@lnmp lnmp.cn]# pecl config-get php_ini

[root@lnmp lnmp.cn]#

可以看到 php_ini 的值是空,可以这样设置(根据自己实际 php.ini 位置修改):

[root@lnmp lnmp.cn]# pecl config-set php_ini /usr/local/php7/lib/php.ini
config-set succeeded
[root@lnmp lnmp.cn]# pecl config-get php_ini
/usr/local/php7/lib/php.ini
[root@lnmp lnmp.cn]#

可以看到已经设置好。

其实这个在安装前就应该设置好的,但事至于此,唯有手动将 raphf 和 propro 加入到 php.ini

[root@lnmp lnmp.cn]# vim /usr/local/php7/lib/php.ini

加入如下内容:

extension=raphf.so
extension=propro.so

关于 raphf 和 propro,具体可以参考这里:

https://mdref.m6w6.name/raphf
https://mdref.m6w6.name/propro

再次安装就能成功安装了

[root@lnmp lnmp.cn]# pecl install pecl_http

如果一开始就设置好 php_ini, 最后的提示会是这样:

install ok: channel://pecl.php.net/pecl_http-3.1.0
Extension raphf enabled in php.ini
Extension propro enabled in php.ini
Extension propro enabled in php.ini
Extension http enabled in php.ini
Extension http enabled in php.ini
Extension http enabled in php.ini

顺便说下,至于 pecl 都有哪些选项,可以通过  pecl help 命令查看。

[root@lnmp lnmp.cn]# pecl help
Commands:
build                  Build an Extension From C Source
bundle                 Unpacks a Pecl Package
channel-add            Add a Channel
channel-alias          Specify an alias to a channel name
channel-delete         Remove a Channel From the List
channel-discover       Initialize a Channel from its server
channel-info           Retrieve Information on a Channel
channel-login          Connects and authenticates to remote channel server
channel-logout         Logs out from the remote channel server
channel-update         Update an Existing Channel
clear-cache            Clear Web Services Cache
config-create          Create a Default configuration file
config-get             Show One Setting
config-help            Show Information About Setting
config-set             Change Setting
config-show            Show All Settings
convert                Convert a package.xml 1.0 to package.xml 2.0 format
cvsdiff                Run a "cvs diff" for all files in a package
cvstag                 Set CVS Release Tag
download               Download Package
download-all           Downloads each available package from the default channel
info                   Display information about a package
install                Install Package
list                   List Installed Packages In The Default Channel
list-all               List All Packages
list-channels          List Available Channels
list-files             List Files In Installed Package
list-upgrades          List Available Upgrades
login                  Connects and authenticates to remote server [Deprecated in favor of channel-login]
logout                 Logs out from the remote server [Deprecated in favor of channel-logout]
makerpm                Builds an RPM spec file from a PEAR package
package                Build Package
package-dependencies   Show package dependencies
package-validate       Validate Package Consistency
pickle                 Build PECL Package
remote-info            Information About Remote Packages
remote-list            List Remote Packages
run-scripts            Run Post-Install Scripts bundled with a package
run-tests              Run Regression Tests
search                 Search remote package database
shell-test             Shell Script Test
sign                   Sign a package distribution file
svntag                 Set SVN Release Tag
uninstall              Un-install Package
update-channels        Update the Channel List
upgrade                Upgrade Package
upgrade-all            Upgrade All Packages [Deprecated in favor of calling upgrade with no parameters]
Usage: pecl [options] command [command-options] 
Type "pecl help options" to list all options.
Type "pecl help shortcuts" to list all command shortcuts.
Type "pecl help version" or "pecl version" to list version information.
Type "pecl help" to get the help for the specified command.
[root@lnmp lnmp.cn]#

前一篇: PHP 7.1 安装 ssh2 扩展
后一篇: http 扩展已经加载,但 http 函数全部不可以用


添加评论

昵称:


验证码