©
このドキュメントでは、 php中国語ネットマニュアル リリース
此 » PECL 扩展未与 PHP 捆绑。
安装此 PECL 扩展相关的信息可在手册中标题为 PECL 扩展的安装章节中找到。更多信息如新的发行版本、下载、源文件、 维护人员信息及变更日志等,都在此处: » http://pecl.php.net/package/pecl_http.
Note: The official name of this extension is pecl_http.
PECL 扩展的 DLL 当前不可用。参见 在 Windows 上构建章节。
[#1] pecl_http_adventure [2015-04-01 03:29:27]
If you are having trouble installing pecl_http 2.x (possibly on Ubuntu 14.04 LTS), pay close attention to the output from phpize when building + installing with pecl.
You'll need to install the system packages outlined at:
http://devel-m6w6.rhcloud.com/mdref/http/
For instance: zlib1g-dev, libcurl4-openssl-dev and libevent-dev
You'll also need to install raphf and propro (SPL should be installed by default with PHP)
You do not need php-http - this is a PEAR class for HTTP_Request.
The PECL install on Ubuntu 14.04 requires the paths to zlib, libcurl and libevent:
where to find zlib [/usr] :
where to find libcurl [/usr] :
where to find libevent [/usr] :
In my instance, libcurl4-openssl-dev was not installed but the PECL package built successfully:
checking for curl/curl.h... not found
and this resulted in a segfault when checking for the extension after installation using `php -i` :
$ php -i
....
http
HTTP Support => enabled
Extension Version => 2.4.1
Used Library => Compiled => Linked
libz => 1.2.8 => 1.2.8
libcurl => disabled => disabled
libevent => 2.0.21-stable => Segmentation fault (core dumped)
Once libcurl4-openssl-dev was installed and the package reinstalled using `pecl install -f pecl_http`, there were no segfaults:
$ php -i
http
HTTP Support => enabled
Extension Version => 2.4.1
Used Library => Compiled => Linked
libz => 1.2.8 => 1.2.8
libcurl => 7.35.0 => 7.35.0
libevent => 2.0.21-stable => 2.0.21-stable
Directive => Local Value => Master Value
http.etag.mode => crc32b => crc32b
Once installed, the class can be found via the 'http' namespace e.g http\Client\Request, not HTTPRequest.
[#2] mikaey at bahjeez dot com [2015-01-02 20:57:24]
For those of you trying to build pecl_http v1 for PHP 5.6, it looks like it doesn't work and it won't be fixed: https://bugs.php.net/bug.php?id=66879&thanks=6
Looks like we are being forced to move to v2...
[#3] TKNL [2014-12-30 00:15:28]
Centos 6.5
Don't use the pecl installer, you can find this module in yum:
yum install php-pecl-http1
[#4] dingxiaosong1987 at gmail dot com [2014-05-22 09:13:46]
centos 6.3 64
compile error
yum install libcurl-devel.x86_64
then ok
[#5] Anonymous [2014-05-10 07:15:52]
On debian 7 I had to do the following:
root@mp1:~# apt-get install php-http
root@mp1:~# apt-get install php5-dev
root@mp1:~# apt-get install libcurl3
root@mp1:~# apt-get install libpcre3-dev
root@mp1:~# apt-get install libcurl4-openssl-dev
root@mp1:~# pecl install pecl_http-1.7.6
add extension=http.so into /etc/php5/apache2/php.ini
root@mp1:~# /etc/init.d/apache2 restart
[#6] Anonymous [2014-04-03 19:30:01]
!!! WARNING !!!
Version 2 of this library is COMPLETELY INCOMPATIBLE with Version 1!
None of the HTTP functions exist in Version 2!
This is NOT stated ANYWHERE in the docs on PHP.net.
From the looks of it Version 2 is a completely OOP interface and drops support for all the functions listed here in the docs.
If you are looking for the functional API use Version 1!
[#7] Anonymous [2014-02-27 14:17:41]
Hi guys
I am configuring this on Ubuntu system and when I tried to run
pecl install pecl_http
it used to fail because it did not find pcre.h
I found out that I need to apt-get install
libcurl4-openssl-dev
libevent-dev
libpcre3-dev - here is where the pcre.h is available
then I run it again and when it asks me for the zlib, libcurl and libevent I specify the respective folders where the src of each of them is located.
So in that way it worked, and the pecl managed to corectly compile a brand new 'http.so' just under '/usr/lib/php5/20090626+lfs/http.so'
Then under both of
/etc/php5/apache2/php.ini
and
/etc/php5/cli/php.ini
I inserted this:
extension=/usr/lib/php5/20090626+lfs/http.so
I'am really not sure which of the php.ini files above is the really correct one.
PS: Sources of zlib, libcurl and libevent if you need to download them manually:
zlib: http://zlib.net/zlib-1.2.8.tar.gz
libcurl: http://curl.haxx.se/download/curl-7.35.0.tar.gz
libevent: https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
[#8] ross dot carver at avantalytics dot com [2014-01-01 21:10:33]
on a amazon linux install with php54, you'll get errors using pecl_http 2.03 from the command line unless you add the following to your php.ini file:
extension=json.so
extension=raphf.so
extension=propro.so
extension=http.so
also make sure chmod ug+x http.so (and any of the other extensions for that matter).
If you do this and get a warning about json.so being already loaded - its likely that there is a separate ini file for json in /etc/php.d/json.ini where this line is included as well. It is necessary that you comment out line in json.ini as it is being called second and causing the warning
environment - php-fpm / nginx
HTH
[#9] csaltos at gmail dot com [2013-12-10 03:02:50]
The pecl_http version 1 is no longer the default major version, so many of the functions and references in this documentation will not work with newer versions.
Try to install the correct pecl_http package for the version 1 you want to use, or refer to a newer version described in the pecl package you want to install.
In my case, I want the version 1, so I issued the command:
pecl install http://pecl.php.net/get/pecl_http-1.7.6.tgz
Ensure you have the latest minor versions for the pecl_http package specified at http://pecl.php.net/package/pecl_http
The documentation for pecl_http version 2 is at http://devel-m6w6.rhcloud.com/mdref/http but I warn you, the version 2 is too different, actually simple functions like http_redirect do not exist in version 2. (I'm wondering, why they did not use a different project name if the version 2 is so different !!)
[#10] d4p3r [2013-11-28 22:10:34]
Look out! Since version 2.0, the extension has been completely renovated. Now you need to pre-load the extensions "raphf", "propro" and "spl". This work for me in Ubuntu 12.04:
apt-get install php-http
pecl install pecl_http
- In php.ini files:
???? extension=raphf.so
???? extension=propro.so
???? extension=http.so
The spl extension is compiled by default in PHP 5.0.0 and since version 5.3.0 can not be disabled.
In addition, instantiation should be done using namespaces nomenclature, such as: new http \ Client ().
Beware! This version is incompatible with version 1 and the event extension.
More information: http://devel-m6w6.rhcloud.com/mdref/http/
[#11] phpsharma at gmail dot com [2013-11-18 07:31:59]
A DLL for this PECL extension is currently unavailable. See also the building on Windows section.
[#12] Anonymous [2013-10-28 15:37:48]
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/http.so' - /usr/lib64/php/modules/http.so: undefined symbol: php_iconv_string in Unknown on line 0
[#13] Anon [2013-08-13 11:50:06]
Latest dlls can be found here: http://windows.php.net/downloads/pecl/releases/http/
[#14] JeroenVD [2013-07-23 16:04:27]
On my Centos 6.4:
chmod +x /usr/lib64/php/modules/http.so
[#15] cheese dot cube at gmail dot com [2013-02-01 08:14:28]
To install this PECL extension on Ubuntu 12.10 run the following:
sudo apt-get install php-http make
sudo pecl install pecl_http
Then add the line "extension=http.so" to php.ini (Normally located at /etc/php5/apache2/php.ini) and restart Apache (sudo service apache2 restart).
[#16] anon at anon dot com [2012-07-22 22:31:21]
For others who can't find pecl_http for PHP 5.3 on Windows...
You can download php_http.dll for PHP 5.3 from the official PHP for Windows site (windows.php.net) at http://downloads.php.net/pierre/
[#17] bruno dot braga at gmail dot com [2012-05-31 03:15:11]
In Ubuntu 12.04:
# (curl-devel equivalent in Ubuntu is libcurl4-gnutls-dev)
sudo apt-get install libcurl3 php5-dev libcurl4-gnutls-dev libmagic-dev
sudo pecl install pecl_http
[#18] aeternuslibertas at gmail dot com [2012-03-06 08:34:04]
If you are on Arch linux you can install this via pear.
just install pear first with pacman, then once php-pear is installed you can # pecl install pecl_http
[#19] Anonymous [2011-07-20 23:19:35]
On Fedora, I had to do 'yum install curl-devel' to avoid missing curl.h error.
[#20] jjrp78 at yahoo dot com [2010-10-25 07:43:57]
in Ubuntu 10.10 I had to create this file:
/etc/php5/conf.d/http.ini
and add this line:
extension=http.so
[#21] srimalj at gmail dot com [2008-03-28 20:55:35]
Just to add to the above.
I had to install the following in Ubuntu 7.10 .
(otherwise I get a message saying missing curl.h)
# apt-get install libcurl4-gnutls-dev
Hope this helps someone the trouble i went into, just to get the http_post_fields function working
Regs
Srimal.
[#22] Mohd Azhar bin Ariffin [2008-02-25 03:20:54]
The installation guideline is very insufficient. I've installed for Debian lenny/sid with the following step;
apt-get install php5-dev (to enable pecl command)
apt-get install libcurl3 (to get curl support)
apt-get install libmagic
and
pecl install pecl_http
pecl will download and compile but before that just follow the prompt. If the respective development library is not available in your system, the compilation will abort.
After pecl_http got install, copy /usr/lib/php5/20060613+lfs/http.so to /usr/lib/apache2/modules and restart apache
Hopefully this will help others from facing the same hassle for quite sometime.
[#23] Jean-Lou Dupont [2008-01-07 12:24:03]
Don't forget to copy ''http.so'' in the php/modules directory and add ''extension=http.so'' to php.ini.
[#24] Christian9997 [2007-06-15 07:09:52]
The "Installation requirements on Windows" are confusing:
If you are a Windows user you need to have the php_curl.dll extension installed before being able to install the php_http.dll extension.