3

Apache is giving me this error

PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: C:/Users/tester/Desktop/Web Server/php-7.2.5-Win32-VC15-x64/ext/curl (The specified module could not be found.), C:/Users/tester/Desktop/Web Server/php-7.2.5-Win32-VC15-x64/ext/php_curl.dll (%1 is not a valid Win32 application.)) in Unknown on line 0

This is a 64bit Windows server 2016 install.

This PHP https://windows.php.net/downloads/releases/php-7.2.5-Win32-VC15-x64.zip

This Apache: https://www.apachelounge.com/download/VC15/binaries/httpd-2.4.33-win64-VC15.zip

All the other modules work+load fine.

I've tried adding the ext path to my system variables.

I've tried using a 32bit version of PHP_curl.dll

I've tried copying libeay32.dll, libssh2.dll, ssleay32.dll into pretty much everywhere. Apache root, ext folder.

What else can I try here?

2
  • 1
    Quoth the PHP manual on curl, installing, and win32 - "Note: Note to Win32 Users In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll, or, as of OpenSSL 1.1 libcrypto-*.dll and libssl-*.dll, must be present in your PATH. You don't need libcurl.dll from the cURL site."
    – ivanivan
    Commented May 21, 2018 at 15:49
  • They all are :-(
    – Mr J
    Commented May 21, 2018 at 15:58

2 Answers 2

13

In the end I had to simply copy libcrypto-1_1-x64.dll, libssh2.dll, libssl-1_1-x64.dll and nghttp2.dll from the PHP folder into the apache bin folder.

3
  • 4
    You sir are a life saver. Tried all sorts of suggestions. Thanks mate. Commented Sep 10, 2019 at 8:03
  • Tnx. The same issue happened to me after updating the PHP from v7.1 to v7.2.
    – userfuser
    Commented Jan 13, 2020 at 1:32
  • 1
    Apache\bin had all but libssh2.dll. Once I added it, everything worked Commented Nov 18, 2022 at 22:15
6

In PHP 7.4:

Most probably it's a problem related only to Windows, if you are using Apache2.4 + Php7, the trick consists in using LoadFile directive to force the loading of CURL as explained in my Mini Guide. You don't need strange things to have CURL working on your machine, you need to edit the file httpd.conf and add this:

LoadFile "${MY_PHP_ROOT}/libssh2.dll"

So full PHP incantation in httpd.conf might look something like this:

##
#BEGIN PHP
Define MY_PHP_ROOT "c:/Dev/PHPs/PHP74"

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "${MY_PHP_ROOT}/php7apache2_4.dll"
PHPIniDir "${MY_PHP_ROOT}/"

# Load library required for CURL
LoadFile "${MY_PHP_ROOT}/libssh2.dll"

#END PHP
##

Hope this helps.

PS: Order of LoadModule/LoadFile doesn't matter.

4
  • 1
    Thank you, this worked for me on Win10 with Apache2.4 and PHP7
    – BigBadMe
    Commented Oct 30, 2020 at 23:51
  • 1
    This solution is by far cleaner than the accepted one and avoids making copies of the dll which will certainly diverge over the time. Commented Feb 1, 2022 at 10:03
  • Note that this works because other libraries are already provided with Apache 2.4. So you probably already have libcrypto-1_1-x64.dll, libssl-1_1-x64.dll and nghttp2.dll in Apache bin folder.
    – Nux
    Commented Mar 9, 2023 at 17:19
  • In PHP 8.1 it works this way: LoadFile "C:/Apache24/php-8.1.21-Win32-vs16-x64/libcrypto-1_1-x64.dll" LoadFile "C:/Apache24/php-8.1.21-Win32-vs16-x64/libssl-1_1-x64.dll" LoadFile "C:/Apache24/php-8.1.21-Win32-vs16-x64/libssh2.dll" nghttp2.dll is also required, but already present in Apache24\bin. Commented Jul 27, 2023 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.