[php] How to enable cURL in PHP / XAMPP

How do I enable cURL in PHP?

??

This question is related to php curl xampp

The answer is


PHP 7^ version:

sudo apt-get install php-curl
sudo service apache2 restart


On Debian with Apache 2:

apt-get install php5-curl
/etc/init.d/apache2 restart

(php4-curl if it's php4)


For Ubuntu (and probably all Debian-Based) Linux Distributions:

sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart 

You might have seen PHP Fatal error: Call to undefined function curl_init() before.


In SUSE Linux:

zypper in php5-curl
rcapache2 restart

I found the file located at:

C:\xampp\php\php.ini

Uncommented:

;extension=php_curl.dll

to install php5-curl under opensuse:

sudo yast2

->software ->software management ->search for curl ->check php5-curl case and accept.

after installation you need to restart apache server

service apache2 restart

If none of the above solves your problem and have installed with php-x86 (Windows 32 bit), then problem may be of openssl - for more info : How to fix libeay32.dll was not found error


Actually I did it by uncommenting extension=php_curl.dll in the xampp\apache\bin\php.ini file.


Basic tip: After enabling the CURL in php.ini file, you need to restart the web server to make it work (my experience says).


Check the php version, If you installed php 7.0 version

sudo apt-get install php7.0-curl
sudo service apache2 restart

If you installed php 5.6 version

sudo apt-get install php5-curl
sudo service apache2 restart

Steps for Windows 7:

  1. Ensure that the php.ini file that the PHP engine uses is the one you think it is.
  2. Ensure extension_dir in php.ini is correctly set to the ext folder
  3. Ensure extension=php_curl.dll in the php.ini is uncommented

Finally and maybe the one most people don't know: 4. Ensure that there are these two files in the Windows System32 folder: libeay32.dll ssleay32.dll If not there, you may copy these two files from the php folder.


For windows OS users (It worked for me) in XAMPP.

step 1: Go to C:\xampp\php\php.ini

edit this file php.ini

find curl- you will see a line ;extension=php_curl.dll.

remove semicolon (;)extension=php_curl.dll. so this line looks like

;extension=php_curl.dll

to

extension=php_curl.dll

step 2: copy ssleay32.dll, libeay32.dll from php folder. paste it in C:\Windows\System32\

step 3: Restart the system . Curl will run successfully.


check if curl module is available

$ ls -la /etc/php5/mods-available/

enable the curl module

$ sudo php5enmod curl

source: http://baligena.com/installing-curl-ubuntu-server/


You can check phpinfo() (create a script containing and browse to it). This will tell you if you really do have it enabled. If not, read here.

It is not recommended for the faint-hearted Windows developer.


Since XAMPP went through some modifications, the file is now at xampp/php/php.ini.


If you're are using MAMP, cURL is enabled by default.


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to curl

What is the incentive for curl to release the library for free? curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number Converting a POSTMAN request to Curl git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to post raw body data with curl? Curl : connection refused How to use the curl command in PowerShell? Curl to return http status code along with the response How to install php-curl in Ubuntu 16.04 curl: (35) SSL connect error

Examples related to xampp

Xampp localhost/dashboard phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO) Is there way to use two PHP versions in XAMPP? Where to find htdocs in XAMPP Mac phpMyAdmin access denied for user 'root'@'localhost' (using password: NO) How to downgrade php from 7.1.1 to 5.6 in xampp 7.1.1? How to turn on/off MySQL strict mode in localhost (xampp)? mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it How to install mcrypt extension in xampp Fatal error: Uncaught Error: Call to undefined function mysql_connect()