445

When i am going to implement Authorize.net payment gateway. However, I got this error:

Call to undefined function curl_init()

Please let me know what is wrong in it.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Pramod Kumar Sharma
  • 7,851
  • 5
  • 28
  • 53
  • 6
    You don't have curl support in your PHP. This question has been [asked many times here](http://stackoverflow.com/search?q=call+to+undefined+function+curl_init) – Shef Jun 17 '11 at 07:20
  • 1
    for PHP7 ... I added php dir path in system enviroment varible, deleted libeay32.dll and ssleay32.dll from apache/bin, keep these dll in php directory and its work. – Wasim A. Mar 17 '18 at 19:10
  • Had this problem but none of these answers worked. The one that did turned out to be here: https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2 – jdmayfield Jun 26 '19 at 10:05
  • If all else fails, it maybe an incompatible (older) version of Apache. Upgrading from 2.4.18 to 2.4.46 fixed the problem for me and others. – pbarney Dec 30 '20 at 17:49

2 Answers2

907

If you're on Windows:

Go to your php.ini file and remove the ; mark from the beginning of the following line:

;extension=php_curl.dll

After you have saved the file you must restart your HTTP server software (e.g. Apache) before this can take effect.


For Ubuntu 13.0 and above, simply use the debundled package. In a terminal type the following to install it and do not forgot to restart server.

sudo apt-get install php-curl

Or if you're using the old PHP5

sudo apt-get install php5-curl

or

sudo apt-get install php5.6-curl

Then restart apache to activate the package with

sudo service apache2 restart
Shurvir Mori
  • 2,288
  • 1
  • 17
  • 29
rahim asgari
  • 12,197
  • 10
  • 43
  • 53
  • 91
    Make sure you restart your Apache server after making this change. – Kevin_TA Dec 22 '11 at 02:52
  • 22
    If this doesn't work, check out [this question](http://stackoverflow.com/questions/12380670/call-to-undefined-function-curl-init-error-in-wamp-2-2). It provides a link for downloading a "fixed" `php_curl.dll` for PHP 5.3.13 (or 5.4.3). I had everything configured right but `curl` just wasn't being loaded (not showing up in `phpinfo()`). This fixed my issue. – Andrew Cheong Nov 12 '12 at 15:09
  • 2
    if you are using from cmd, there is anoher php.ini file, more info there: http://stackoverflow.com/questions/2750580/how-to-find-the-php-ini-file-used-by-the-command-line – Dariux Jan 22 '14 at 12:37
  • 9
    on linux, you uncomment or add `extension=php_curl.so` in your php.ini and restart apache – Mladen Danic Mar 05 '15 at 13:54
  • @AndrewCheong, Weird, why would you have a corrupted `php_curl.dll`? Are you sure you downloaded the official PHP from php.net? – Pacerier Jul 16 '15 at 10:37
  • @FrancoisDeschenes, Wouldn't `extension=php_curl.so` work on Linux/Unix/OSX? – Pacerier Jul 16 '15 at 10:38
  • 1
    works fine in ubuntu 15.10 and no need to change the php.ini – open-ecommerce.org Nov 09 '15 at 14:04
  • 1
    Issue with dependencies - the command with dependencies for Ubuntu 14.04 here is : "sudo apt-get install curl libcurl3 libcurl3-dev php5-curl" source: "http://askubuntu.com/questions/530323/how-to-make-curl-and-php-available-when-installed-from-xampp" – Dung Mar 29 '16 at 15:10
  • On Ubuntu Apache, it was not enough to add the extension to php.ini, I also had to add it to /etc/php5/apache2/conf.d/20-curl.ini, – intotecho Aug 05 '16 at 01:21
  • 1
    So for php 5.6 u need to `sudo apt-get install php5.6-curl` ... :I . On my envoirement curl was woriking fine on the nginx server but when i tried to use it in phpunit it gave me an error. That could be the same for other libs like php-xml ... i needed to install 5.6 explict! – Simon Müller Aug 18 '16 at 13:54
  • 6
    ```sudo apt-get install php-curl``` then ```sudo service apache2 reload``` done! – zeros-and-ones Nov 16 '16 at 17:15
  • Didn't work for me in Windows, fixed by copying `libeay32.dll`, `libsasl.dll` and `libssh2.dll` from folder contains `php.exe` to `C:\Windows\System`, `C:\Windows\System32` and `C:\Windows\SysWOW64` – Pavel May 03 '17 at 10:15
  • If you are running Linux, as @Simon said, don't forget to restart apache for the change to take effect. – Angel115 Aug 16 '17 at 19:28
  • NginX did not require a restart. "apt-get install php-curl" on Debian 9 worked. – PJ Brunet Oct 03 '17 at 18:09
  • For Ubuntu 16.04, sudo apt-get install php7.0-curl – Henry Jan 03 '18 at 14:05
  • Thanks, just don't forget to ´sudo service apache2 restart´ (if on LAMP) – Silver Ringvee Jan 28 '18 at 18:42
  • I used php5.6 on ubuntu so `apt-get install php5.6-curl` worked fine also. Apt-get couldn't locate `php5-curl` with an error. – kujiy Mar 05 '18 at 05:02
  • Apache 2.4.18 won't load Curl (even if it is checked in wamp). You have to update your Apache version to make it work. – Jibato Jul 31 '18 at 15:08
  • If after making this it still does not works, then read this (on Windows): https://stackoverflow.com/a/49747761/3255692 – csr-nontol Dec 19 '18 at 17:50
  • for a fresh ubuntu 18 `sudo apt install php-curl` worked for me – mork Jan 22 '19 at 12:55
  • this answer is pure evil :-D – icy Jun 09 '19 at 13:25
  • 2
    In ubuntu check php version by `php -v`. my php version was `7.3`. install php curl based on your version `apt-get install php7.3-curl`. restart your apache2 `service apache2 restart` – mohammad asghari Jul 21 '20 at 08:25
  • 1
    note in my case the entry doesn't have the PHP prefix; it's like that: `extension=curl` – Menelaos Kotsollaris Sep 16 '20 at 21:54
18

The CURL extension ext/curl is not installed or enabled in your PHP installation. Check the manual for information on how to install or enable CURL on your system.

Stefan Gehrig
  • 82,642
  • 24
  • 155
  • 189
  • 3
    (Win32) I also had to add `c:\php` to my PATH. I learned that reading the manual from the link above. The manual said `libeay32.dll` and `ssleay32.dll` must both be on the PATH for the module to work. – Jonathan Nov 17 '16 at 20:49