In order to use handy HTTP extension in your PHP code you need to use install it first, as it doesn’t come with PHP core installation.
Below are the steps to install it on CentOS:
- Install PHP Pear if not installed yet:
yum install php-pear
- Install GCC if not installed yet:
yum install gcc
- 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
- Start the main installation:
/usr/bin/pecl install pecl_http
You can use default values when answering installation questions
- Add the following line to /etc/php.ini file:
extension=http.so
- 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 🙂