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

On Debian with Apache 2:

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

(php4-curl if it's php4)

Solution 3

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.

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.

Share:
439,166

Related videos on Youtube

Fero
Author by

Fero

C00L Developer....

Updated on March 04, 2020

Comments

  • Fero
    Fero about 4 years

    How do I enable cURL in PHP?

    ​​

    • Dave Archer
      Dave Archer over 14 years
      windoze or linux?
    • Fero
      Fero over 14 years
      windows. 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
      Vikrant Vir Bhalla almost 8 years
      A basic curl tutorial very easy to learn -> technofusions.com/curl-in-php-tutorial-basics
  • Question Mark
    Question Mark over 14 years
    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?
  • Nelson
    Nelson over 12 years
    Note the restart is necessary.
  • freespace
    freespace about 12 years
    +1 to @Nelson. The post install /looks/ like it does a restart, but it really does a reload.
  • Nick Bolton
    Nick Bolton almost 12 years
    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.
  • Mathias Bak
    Mathias Bak almost 12 years
    If it fails, try to update repositories with "apt-get update"
  • lumbric
    lumbric almost 12 years
    Also it wasn't sufficient to reload apache. I had to restart it.
  • veljkoz
    veljkoz over 11 years
    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: stackoverflow.com/q/10939248/79444
  • felix021
    felix021 almost 11 years
    In addition to the 4th requirement, for win7 64bit, those 2 files should go C:\windows\SysWOW64.
  • Dibish
    Dibish over 8 years
    @WaiKit Kung you are awesome..done the 4th step and worked for me. Thank you.
  • HartleySan
    HartleySan over 7 years
    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.
  • Luud van Keulen
    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
    Guttemberg over 6 years
    Simple. Very nice
  • Márcio Rossato
    Márcio Rossato over 3 years
    sudo service apache2 reload works too, I believe the reload is more indicated to not stop the server.