17

I am using Windows10 64 bit Apache 2.4.25 (Win64) PHP 7.1.0-Win32-VC14-x64

when i try calling curl_init() function, i get an error saying "Call to undefined function curl_init()" tried following

  • copying ssleay32.dll & libeay32.dll & php7ts.dll to apache/bin folder
  • setting path properly to include above files "C:/PHP;"

Any help much appreciated.

Sonic
  • 183
  • 1
  • 1
  • 7
  • 2
    I am trying to solve this same issue. Do you see a message in your Event Viewer -> Windows Logs -> Application saying "Unable to load dynamic library '{php ext path}\php_curl.dll'"? – bnp887 Jan 24 '17 at 09:01
  • Try copying libssh2 from the php folder into the apache/bin folder as well, that just worked for me now. – bnp887 Jan 24 '17 at 09:07
  • 2
    copied libssh2 file from php7 folder to apache/bin, no success. Did u change anything else apart from libssh2 copying? – Sonic Jan 25 '17 at 10:11
  • I did change quite a bit since I started by getting the latest version of php. So all the steps as best as I can remember were: 1) download php 7.1 2) add php folder to PATH 3) update ini file with absolute path for extension directory and uncommented php_curl.dll and php_openssl.dll extensions 4) updated httpd.conf to load php7apache2_4.dll module in php folder and set PHPIniDir to php directory 5) copy libeay32.dll libssh2.dll and ssleay32.dll into apache/bin (replace existing) 6) restarted apache. – bnp887 Jan 25 '17 at 16:27
  • If the last comment does not work, try having a look at errors in Event Viewer -> Windows Logs -> Application and seeing what the message is saying there. – bnp887 Jan 25 '17 at 16:29
  • thanks a lot @wclear your answer saved my life, i had same issue regarding curl – Pedro Mar 10 '17 at 14:50
  • @wclear - upgrading to 7.1.2 worked. Thanks :) – Sonic Mar 14 '17 at 14:40
  • Thanks @Pedro and Sonic, since those steps seem to have worked in a few cases now, I copied them into an answer as well. – bnp887 Mar 19 '17 at 16:49

8 Answers8

32

Here are the steps from obtaining PHP to enabling cURL:

  1. Download PHP (these steps tested with 7.1)
  2. Add PHP folder to PATH environment variable
  3. Update php.ini file with absolute path for extension directory and uncomment php_curl.dll and php_openssl.dll extensions
  4. Update httpd.conf (Apache config file) to load php7apache2_4.dll module in PHP folder and set PHPIniDir to PHP directory
  5. Copy libeay32.dll libssh2.dll and ssleay32.dll into apache/bin (replace existing)
  6. Restart Apache.
bnp887
  • 5,128
  • 2
  • 26
  • 30
  • Thank you sir! I spent 3 days trying to get this to work. I would fellow the guides and install the VC14 redist. It would work for a while and then revert to where the extensions would not load. I feared I would never get it working, but copying the DLLs did the trick. This is the first time I've had this problem with Apache/PHP on Windows over the last 10+ years where I had to do this. Very strange. – Reactgular May 18 '17 at 18:19
  • 9
    Just ran into this issue with Apache 2.4.29 and PHP 7.2.0 (both x64). My install of PHP (straight from windows.php.net) didn't have a bunch of files you listed. I copied `libssh2.dll` to my Apache `bin/` and it worked. Lifesaver. – sheng Jan 05 '18 at 02:52
  • 3
    PHP 7.2.2 Windows 10 Apache 2.4 After a while of searching for answers why the cURL library doesn´t load, i just copied libssh2.dll from \php to \Apache24\bin and everything started to work just fine – Prasannjit Feb 07 '19 at 09:27
  • I had issue with none of the uncommented PHP extensions not loading (PHP's path was in PATH and PC restarted). Point number three did the trick for me (Win 10, PHP 7.3.2, Apache 2.4.38). Point number 5 is bad advice. If PHP dir is set in Apache's conf file, then Apache will load them. – Gustav Feb 17 '19 at 18:46
  • 1
    Life saver! I copied libssh2.dll to my Apache bin/ and it worked – user3415805 Jun 20 '19 at 12:31
  • @ShengSlogar where did you find those files? – Tobia May 25 '20 at 13:45
  • @Tobia Download the x86 ZIPs.They're in `/ext` – sheng May 26 '20 at 00:42
  • Thanks, I was looking into the x64 package – Tobia May 26 '20 at 08:14
  • 2
    its worth noting some of the versions of php 7 do not show the extension of *.dll e.g it will be just extension=curl as opposed to extension=curl.dll on the php.ini file. therefore be careful while uncommenting the extensions – young pac Feb 03 '21 at 17:37
21

I fixed it by:

1)Edit php.ini file Enable( uncomment) php_curl.dll and php_openssl.dll extensions

2)go to c:/php7/

Copy libssh2.dll into c:/apache24/bin folder.

3) test by: curl_test.php

<?php

// Script to test if the CURL extension is installed on this server

 // Define function to test
    function _is_curl_installed() {
if  (in_array  ('curl', get_loaded_extensions())) {
    return true;
}
else {
    return false;
}
}

// Ouput text to user based on test
 if (_is_curl_installed()) {
    echo "cURL is <span style=\"color:blue\">installed</span> on this server";
  } else {
  echo "cURL is NOT <span style=\"color:red\">installed</span> on this server";
}
?>
hoogw
  • 4,982
  • 1
  • 37
  • 33
  • copying libssh2.dll to apache/bin folder helped in my case with loading "curl" extension, however it did not help with LDAP extension. :( i guess that depends on different libraries – Pavel Cernik Apr 24 '18 at 04:46
  • This is the only thing that is lacking in my setup: "Copy libssh2.dll into c:/apache24/bin folder", took me 2 hrs! Thank you sir! – Tinker Jun 30 '21 at 07:49
12

in PHP 7.2.2 Windows 10 Apache 2.4 After a while of searching for answers why the cURL library doesn´t load, i just copied libssh2.dll from \php to \Apache24\bin and everything started to work just fine

Carlos
  • 121
  • 1
  • 2
  • Worked for me. After PHP 7.2 it seems libleay32.dll and ssleay32.dll aren't provided, so I was chasing my tail with other fixes trying to test if this was a PATH issue or something corrupt. – Jacob Cruz Mar 26 '19 at 19:57
  • 1
    For php 7.2.18 I also needed to copy libcrypto-1_1.dll and libssl-1_1.dll. This works the same way for php 7.3 (even with the dlls from php 7.2 :). – jfx May 29 '19 at 13:42
  • I have Git v2.2.7 installed and I found a copy of libssh2-1.dll where Git is installed. I copy this file to \Apache24\bin and renamed it to libssh2.dll. After restarting Apache service, phpinfo() reports curl support is enabled. This is for php 7.4.25 on Windows 10. (DLL was here: C:\Program Files\Git\mingw64\bin) – Karl Oct 29 '21 at 22:51
5

I had the same issue with Acquia's Dev Desktop, copying the libcrypto-1_1-x64.dll and libssl-1_1-x64.dll from the PHP7.3 folder to the Apache/bin folder resolved the issue for me.

"Beginning with version 1.1.0 OpenSSL did change their libary names! libeay32.dll is now libcrypto-.dll (e.g. libcrypto-1_1-x64.dll for OpenSSL 1.1.x on 64bit windows) ssleay32.dll is now libssl-.dll (e.g. libssl-1_1-x64.dll for OpenSSL 1.1.x on 64bit windows)"

  • epos_jk

See https://www.php.net/manual/en/curl.installation.php#121921.

deronimo
  • 121
  • 2
  • 6
2

After spending countless hours or even days trying out all the posted solutions on stackoverflow and elsewhere, the only thing that worked for me in 2022 was the following solution, (taken from this comment to the php cURL manual)

Try add to these strings to apache config (httpd.conf):

# manually load SSL libraries for cURL
LoadFile "(path\to\php)\libssh2.dll" 
LoadFile "(path\to\php)\libcrypto-1_1-x64.dll" 
LoadFile "(path\to\php)\libssl-1_1-x64.dll"

and restart apache (dont forget to use your php folder name);

Don't know if this matters, but I am on Windows 7, using Apache 2.4 and PHP 7.4. I don't have any WAMP/XAMP server installed on my system. Instead I downloaded the ZIPped versions and start them manually from my local non-system drive whenever I need to use localhost.

Also, after it finally worked, I deleted libeay32.dll, ssleay32.dll from C:/Windows/System32 and from Apache/bin.

dominman
  • 23
  • 4
0

Here is what worked for me...

Env Info

  • WAMP Server version 3.1.9
  • Apache 2.4.39
  • PHP 7.2.18

Step 1

From PHP downloads, I got VC15 x64 Thread Safe (2019-May-01 10:48:48) https://windows.php.net/download#php-7.2

Step 2

Extracted the zip file and copied /ext/php_curl.dll to C:\wamp64\bin\php\php7.2.18\ext directory (By overwriting)

Step 3

Restarted all services

DONE

Zortext
  • 566
  • 8
  • 21
0

This save my life (from https://www.php.net/manual/en/curl.installation.php)

Upgrading to php 7.1.6 on Apache 2.4 32bit version Windows 7 x64

this curl implementation works:

  1. C:/(path to php folder)/php.ini enable extension=php_curl.dll

libeay32.dll, ssleay32.dll, libssh2.dll find directly in php7 folder

  1. add this to Apache/conf/httpd.conf
    # load curl and open ssl libraries  
    LoadFile "C:/(path to php folder)/libeay32.dll"  
    LoadFile "C:/(path to php folder)/ssleay32.dll"
    LoadFile "C:/(path to php folder)/libssh2.dll" 
    

If you don't find some of this DLLs, try downloaidng non-TS version fo php and copy them from that folder.

dominman
  • 23
  • 4
Handsome Nerd
  • 17,114
  • 22
  • 95
  • 173
-1

I copied from php main folder to apache24 bin folder the following dll

libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
libssh2.dll

and it worked like a charm

and restart apache server my windows is 10 and my php version is php 8.0.28 - apache 2.4.57-win64

Tyler2P
  • 2,324
  • 26
  • 22
  • 31