How to enable cURL in PHP / XAMPP
439,166
Solution 1
Since you're using XAMPP, uncomment the line
;extension=php_curl.dll
in xampp\apache\bin\php.ini
, and then restart the Apache service.
NB: In newer XAMPP versions, PHP has moved to root xampp folder xampp\php\php.ini
.
Solution 2
apt-get install php5-curl
/etc/init.d/apache2 restart
(php4-curl if it's php4)
Solution 3
Steps for Windows 7:
- Ensure that the php.ini file that the PHP engine uses is the one you think it is.
- Ensure extension_dir in php.ini is correctly set to the ext folder
- 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.
Solution 4
I found the file located at:
C:\xampp\php\php.ini
Uncommented:
;extension=php_curl.dll
Solution 5
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.
Related videos on Youtube
Comments
-
Fero about 4 years
How do I enable cURL in PHP?
-
Dave Archer over 14 yearswindoze or linux?
-
Fero over 14 yearswindows. Thanks David. i solved it.. Actually i did it by uncommenting the extension=php_curl.dllin the xampp\apache\bin\php.ini file
-
Vikrant Vir Bhalla almost 8 yearsA basic curl tutorial very easy to learn -> technofusions.com/curl-in-php-tutorial-basics
-
-
Question Mark over 14 yearsDid you restart xampp? Did you get an error in your xampp log file? Do you have php_curl.dll in your xampp php extensions directory?
-
Nelson over 12 yearsNote the restart is necessary.
-
freespace about 12 years+1 to @Nelson. The post install /looks/ like it does a restart, but it really does a reload.
-
Nick Bolton almost 12 yearsNelson: It shouldn't be necessary, but it was for me. Even though apt-get restarted apache, it didn't work until I restarted it myself a 2nd time. Strange.
-
Mathias Bak almost 12 yearsIf it fails, try to update repositories with "apt-get update"
-
lumbric almost 12 yearsAlso it wasn't sufficient to reload apache. I had to restart it.
-
veljkoz over 11 yearsActually, this wasn't the issue, since php isn't hosted in IIS, but in Apache(with wamp). It turns out that wamp came out with incompatible versions... had to add apache 2.2.9, and php 5.3.1, and use wami tray->Apache(or PHP)->Version->____ to switch to those versions, as described here: stackoverflow.com/q/10939248/79444
-
felix021 almost 11 yearsIn addition to the 4th requirement, for win7 64bit, those 2 files should go C:\windows\SysWOW64.
-
Dibish over 8 years@WaiKit Kung you are awesome..done the 4th step and worked for me. Thank you.
-
HartleySan over 7 yearsI had to add the following to my PHP code to get things to work:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Maybe that's the issue. -
Luud van Keulen about 7 years
Ensure extension_dir in php.ini is correctly set to the ext folder
That did the job for me. -
Guttemberg over 6 yearsSimple. Very nice
-
Márcio Rossato over 3 yearssudo service apache2 reload works too, I believe the reload is more indicated to not stop the server.