Linux – Post compiled php 5.4 curl installation

centoscurlinstallationlinuxPHP

I recently compiled php 5.4 from source. I have Centos 6. I used this configuration:

# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
# make
# make install
# cp php.ini-dist /usr/local/lib/php.ini

I realize now that I do not have cURL installed. I don't know how to install cURL after a compiled installation of php. Using yum install php-curl installs cURL for php 5.3. I tried this already with an apache restart and it did not show up on my phpinfo file.

How do I install cURL under these circumstances?

Best Answer

Reinstall

As you've install PHP from source, you'll need to recompile PHP to include CURL.

# Return to PHP source directory
sh ~> cd /path/to/php/src

# Clean previus build
sh ~> make clean

# Configure with CURL
sh ~> ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-curl

# Compile & Reinstall PHP
sh ~> make
sh ~> sudo make install

Enable CURL without re-installing

Another option would be to build a shared-object CURL extension, and enable it within your php.ini file. The configuration format for PHP shared-object follows --with-<name>=shared,<path-to-lib>. Repeat the make clean step, and use the following configuration flags:

# Configure CURL for shared object ( you may need to use --with-curl=shared,/usr )
sh ~> ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-curl=shared

# Compile
sh ~> make

# Copy shared-object to php extensions (paths may differ)
sh ~> sudo cp -p modules/curl.so /usr/local/lib/php/extensions/no-debug-non-zts-BUILD_ID/curl.so

# Enable CURL into systems php.ini
sh ~> sudo echo 'extension=curl.so' >> /usr/local/lib/php.ini

Test

Easiest way to test if curl is enabled

# List all PHP modules & filter on CURL
sh ~> /usr/local/bin/php -m | grep curl
curl