Tuesday, 10 January 2012

Install PECL_HTTP on CentOS

In order to use handy HTTP extension in your PHP code you need to install it first, as it doesn't come with PHP core installation.

Below are the steps to install it on CentOS:
  1. Install PHP Pear if not installed yet:
    yum install php-pear
  2. Install GCC if not installed yet:
    yum install gcc
  3. Install cURL if not installed yet:
    yum install curl-devel
    Otherwise you'll get the following message while installing PECL_HTTP:
    configure: error: could not find curl/curl.h

  4. Start the main installation:
    /usr/bin/pecl install pecl_http
    You can use default values when answering installation questions

  5. Add the following line to /etc/php.ini file:
    extension=http.so
  6. Restart your apache server so the extension can be loaded:
    httpd -k restart
You should now be able to use it. hope I saved you some time :)

4 comments:

Pal said...

Thanks for this post Filip. I had to install php-devel (yum install php-devel) otherwise phpize is not present to build http.so.
Unfortunately, after restarting my env, the following error is raised :
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/http.so' - /usr/lib/php/modules/http.so: undefined symbol: Z_ADDREF_P in Unknown on line 0

Guillaume Dorbes said...

Great help ! Thanks

Kęstutis Vaškevičius said...

I also had to install php-devel, but then I tried to install I got zlib error and then I installed zlib: yum install zlib-devel

Unknown said...

thanks Filip