How to enable cURL in PHP / XAMPP
Asked Answered
F

18

159

How do I enable cURL in PHP?

​​

Footboy answered 28/8, 2009 at 13:53 Comment(3)
windoze or linux?Lawgiver
windows. Thanks David. i solved it.. Actually i did it by uncommenting the extension=php_curl.dllin the xampp\apache\bin\php.ini fileFootboy
A basic curl tutorial very easy to learn -> technofusions.com/curl-in-php-tutorial-basicsHallette
P
132

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.

Poignant answered 28/8, 2009 at 14:26 Comment(0)
T
227

On Debian with Apache 2:

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

(php4-curl if it's php4)

Thao answered 28/8, 2009 at 14:13 Comment(6)
Note the restart is necessary.Crucifix
+1 to @Nelson. The post install /looks/ like it does a restart, but it really does a reload.Granule
Nelson: 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.Illgotten
If it fails, try to update repositories with "apt-get update"Pyle
Also it wasn't sufficient to reload apache. I had to restart it.Yand
Simple. Very niceElectrodialysis
P
132

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.

Poignant answered 28/8, 2009 at 14:26 Comment(0)
O
21

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.

Orel answered 18/7, 2012 at 13:0 Comment(5)
Actually, 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: https://mcmap.net/q/83180/-php-curl-not-working-wamp-on-windows-7-64-bit/79444Gabionade
In addition to the 4th requirement, for win7 64bit, those 2 files should go C:\windows\SysWOW64.Rootless
@WaiKit Kung you are awesome..done the 4th step and worked for me. Thank you.Fribourg
I 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.Nothingness
Ensure extension_dir in php.ini is correctly set to the ext folder That did the job for me.Buggy
F
11

I found the file located at:

C:\xampp\php\php.ini

Uncommented:

;extension=php_curl.dll
Friable answered 8/2, 2012 at 0:34 Comment(0)
S
8

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.

Sarita answered 15/5, 2014 at 21:30 Comment(0)
P
6

In SUSE Linux:

zypper in php5-curl
rcapache2 restart
Petrina answered 26/3, 2012 at 22:42 Comment(0)
S
4

You compile your PHP using --with-curl.

Sheepshank answered 28/8, 2009 at 13:59 Comment(0)
P
3

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

Parceling answered 29/11, 2010 at 18:39 Comment(0)
P
3

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

Peculiarity answered 30/9, 2011 at 1:13 Comment(0)
V
3

PHP 7^ version:

sudo apt-get install php-curl
sudo service apache2 restart
Vladamar answered 9/1, 2019 at 11:53 Comment(1)
sudo service apache2 reload works too, I believe the reload is more indicated to not stop the server.Lusaka
A
2

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

Adagio answered 29/8, 2011 at 14:33 Comment(0)
F
1

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

Footboy answered 3/10, 2009 at 7:10 Comment(0)
R
0

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.

Rugby answered 28/8, 2009 at 13:59 Comment(2)
nope Mark.. I am in need to ENABLE cURL support exactly. Actually i did it by uncommenting the extension=php_curl.dllin the xampp\apache\bin\php.ini file . But it does not reflect. Any more IdeaFootboy
Did 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?Rugby
S
0

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.

Shortterm answered 28/2, 2016 at 7:40 Comment(0)
A
0

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/

Adamite answered 28/8, 2016 at 11:47 Comment(0)
C
0

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
Concessive answered 15/5, 2018 at 6:33 Comment(0)
I
0

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

Importance answered 4/3, 2019 at 4:45 Comment(0)
D
-1

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
Demoniac answered 30/6, 2014 at 11:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.