40

Follow-up from my post yesterday (Enabling cURL with PHP)

The problem is that PHP isn't able to load php_curl.dll. I've tried several steps including uncommenting extension=php_curl.dll, making sure the dependencies libeay32.dll and ssleay32.dll eixst in the path, re-downloading php_curl.dll, replacing the old one, and lastly copying the file into my System32 folder.

I'm using Apache 2.2 and PHP 5.4.14. I installed both using their individual packages; I'm not using XAMP or WAMP. I'm using Windows 7 64-bit.

Any help at all would be appreciated.

8
  • 1
    possible duplicate of Enabling cURL with PHP
    – Marc B
    May 7, 2013 at 16:35
  • i had this problem there is a solution which i don't think i give without breaking the rules. - ---removed-- - if this does break the rules please edit/ delete thanks
    – unasAquila
    May 7, 2013 at 16:38
  • Same problem, but no answer on that thread May 7, 2013 at 16:38
  • I installed PHP and Apache using their individual packages. I'll edit my post to reflect that. Thanks for the response though! May 7, 2013 at 16:39
  • ok edit your question to not include the other tools just say clean install no 3rd party program used
    – unasAquila
    May 7, 2013 at 16:42

16 Answers 16

77

libeay32.dll and ssleay32.dll have to be path-accessible for php_curl.dll loading to succeed.

But copying them into Apache's ServerRoot, Apache's \bin\, Window's \System32\, or even worse into the Windows main directory is a bad hack and may not even work with newer PHP versions.

The right way to do it is to add the PHP path to the Windows Path variable.

  1. In Control Panel -> System click on Advanced System Settings or press WIN+R and type SystemPropertiesAdvanced
  2. Click the button Environment Variables.
  3. Under System Variables you will find the Path variable. Edit it and prepend C:\PHP; to it - or whatever the path to your PHP folder is.
    (Hint: If your PHP folder contains spaces like C:\Program Files\PHP you may need to use the short filename form here, i.e. C:\Progra~1\PHP.)
  4. Then fully stop Apache and start it again (a simple restart might not be enough).

Update 2017-05:
I changed the instructions above to prepend the Path variable with the PHP path instead of appending to it. This makes sure that the DLLs in the PHP path are used and not any other (outdated) versions in other paths of the system.

Update 2018-04:
If you have already chosen the wrong way and copied any of the PHP DLLs to Apache or Windows paths, then I strongly recommend that you remove them again! If you don't, you might get into trouble when you later try to update PHP. If a new PHP version brings new versions of these DLLs, but your old DLLs still linger around in system or webserver paths, these old DLLs might be found first. This will most certainly prevent the PHP interpreter from starting. Such errors can be very hard to understand and resolve. So better clean up now and remove any of the mentioned DLLs from Windows and Apache paths, if you copied them there.
(Thanks to @EdmundTam and @WasimA. for pointing out this problem in the comments!)

Update 2019-10:
Tip: To find all copies of these DLLs and check whether you might have placed them in the wrong folders, you can use the following commands in a Windows Command Prompt window:

dir c:\libeay32.dll /s
dir c:\ssleay32.dll /s

Be warned that these commands may take some time to complete as they search through the entire directory structure of your system drive C:.

Update 2020-08:
If your PHP folder contains spaces (i.e. C:\Program Files\PHP) you may need to use the short filename form in the Path variable at step 3 (i.e. C:\Progra~1\PHP). Thanks to @onee for this tip!

23
  • 8
    This was what finally worked for me - no custom dll nonsense required.
    – J c
    Dec 2, 2014 at 9:31
  • 6
    Adding the PHP directory to the PATH variable was the thing to do in my case. Thanks.
    – kmas
    May 19, 2015 at 14:26
  • 3
    Just wanted to add that after adding the PATH variable restarting apache using -k restart was not enough for me. I had to stop it completely then start it again.
    – Sean256
    Nov 9, 2015 at 20:03
  • 2
    This worked for me, but I just wanted to add that I had to restart windows in order for this to work. Just restarting Apache was not good enough.
    – brant
    Nov 3, 2016 at 17:28
  • 3
    To me, I need to delete libeay32.dll, libssh2.dll, ssleay32.dll and nghttp2.dll which I copied to apache\bin and system32. I even forgot when I copied nghttp2.dll to apache\bin, and it took me more than a week to figure it out.
    – Edmund Tam
    Apr 15, 2018 at 9:46
17

In PHP 5.6.x version You should do the following:

Move to Windows\system32 folder DLLs from php folder:

libssh2.dll, ssleay32.dll, libeay32.dll and php_curl.dll from php ext folder

Move to Apache24\bin folder from php folder:

libssh2.dll

Also, don't forget to uncomment extension=php_curl.dll in php.ini

7
  • 17
    Just copying the libssh2.dll file to Apache24\bin worked.. thanks! so weird o.O
    – Salman
    Jul 21, 2015 at 15:10
  • 7
    This helped me a lot with PHP 7 (x64) + Apache 2.4.18 (x64) on Win7 x64. However I just used LoadFile "[path to php]\libpq.dll" and LoadFile "[path to php]\libssh2.dll" for loading cURL and PgSQL extensions. No filemoves needed. Just load them with LoadFile directive in httpd.conf.
    – BlitZ
    Dec 14, 2015 at 12:38
  • don't need to copy libssh2.dll to apache
    – Robert
    Jun 9, 2016 at 19:08
  • @Num6 I am trying from many days, but its not working. Could you please explain you successfully did php7, apache2.4, I am on win10 x64. please upload your dll files somewhere.
    – Wasim A.
    Dec 11, 2016 at 18:25
  • copying libssh2.dll file to Apache24\bin worked for me too
    – Kiran
    Jan 5, 2018 at 22:03
17

WINDOWS Apache 2.4.x + PHP 7.0.x SOLUTION HERE:

Solution: Put libeay32.dll, libssh2.dll, ssleay32.dll files under dir specified in httpd.conf's ServerRoot directive. These dlls can be found compiled under php root folder.

Reasons:

Problem is php_curl.dll requires to access following libraries while loading: libeay32.dll, libssh2.dll, ssleay32.dll and it does not make sense if you put them in ./php/ext dir or if you put PHP extensions in PHP root dir.

Of course you can put them in C:\Windows or in some global folder defined in PATH but if you don't want to do this and you want that your apache+php installation was portable:

The path specified in ServerRoot in httpd.conf is treated as home path for php. The behaviour is similar to situation where you include ./path/to/some.php file in ./index.php and home path for some.php file is still ./ the dir where index.php resides.

In shorts just put those three dlls right in dir you specified in httpd.conf ServerRoot directive and php_curl.dll will not fail to load again.

9
  • 1
    I had to place the dlls in apache's bin dir (and replace the existing ones) to make it work.
    – todinov
    Feb 2, 2016 at 20:42
  • 2
    Yup, putting these files from my PHP directory into Apache24/bin and restarting Apache worked for me. Thanks!
    – Hobbes
    Oct 20, 2016 at 20:13
  • And if you have multiple virtual hosts, do you really copy PHP files into each of your ServerRoots? I consider this hard to maintain, hard to update and thus a really bad hack. Try the Path solution. It is clean and maintainable.
    – Jpsy
    Oct 25, 2016 at 1:38
  • @Jpsy you are talking about VirtualHost Directory which is different than ServerRoot path. VirtualHosts have same ServerRoot and different Directory.
    – BIOHAZARD
    Oct 25, 2016 at 10:04
  • 1
    Unfortunately this isn't a great solution if you use WAMP with multiple versions of PHP installed, as I expect that they may all have their own versions of those DLLs. WAMP seems to handle some aspects of this with symlinks, but I'm not sure exactly how it configures them.
    – Simon E.
    Jul 4, 2017 at 5:08
6

You are loading .dll so your OS has to be windows.

First check which php.ini file you are using by running phpinfo()

Then check where your extensions folder is by checking extension_dir attribute in that file.

Next make sure that php_curl.dll is present in that folder. If not copy it over.

Restart apache and check if it works.

Since you installed packages individually, also do this:

Copy the dll file from php_installation_folder/extensions to apache_installation_folder/bin

6
  • Ok, which PHP are you running? Is it 64 bit? If you are running 64 bit PHP, and having a 32 bit curl dll you can get this error. Actually this is already covered in SO. stackoverflow.com/questions/10939248/…
    – raidenace
    May 7, 2013 at 16:53
  • I'm running 32 bit PHP and I'm pretty sure the curl dll is x86 also (it came with the installation). I've already reviewed the post you've linked, and since all the fixed dlls are for x64 PHP I haven't been able to use it. I didn't see when I first installed PHP (windows.php.net/download/#php-5.4) a x64 version so that's why I installed 32 bit :P Do you think I should find and install x64 PHP instead? Thanks again for your help, I really appreciate it. May 7, 2013 at 17:06
  • I do not think you need to do that. Did you copy dependencies to apache/bin as well?
    – raidenace
    May 7, 2013 at 17:08
  • Oh! I didn't and now it works!! Thank you so much!! Do you mind explaining why the dlls need to be placed in apache/bin? I thought only PHP needed to see them? Thanks again though, I've been struggling with this problem for so long. May 7, 2013 at 17:16
  • 2
    @user2066880 Thats great! What happens when you have separate installations for Apache and PHP is that I believe PHP gets installed as a CGI module (this is not same as CLI) and not a proper apache extension. What this means is that php will request apache for (some) extensions loading and apache naturally checks in its bin folder and tells PHP whether it got it or not. Which is why PHP gives the misdirected error message. I used to know how to fix this, but its been years since I have used separated configurations. Glad it worked though! :-)
    – raidenace
    May 7, 2013 at 17:38
4

Usually this is an OpenSSL version mismatch error, between Apache and PHP. In case Apache loads PHP as a DSO module, its own OpenSSL versions (dlls and libs) will be used. So, in case the PHP extension requires a newer version, it may not find the appropriate interface inside the Apache-loaded DLLS and it will fail to work.

Since you need the PHP extension to load, you need the relevant DLL files to be at least the version of what the PHP module asks for. Supposing that you 're using lastest builds for both Apache and PHP and both having been built with the same MVC version, you can copy the following files:

  • libcrypto-1_1.dll
  • libcrypto-1_1-x64.dll
  • libcurl.dll
  • libsasl.dll
  • libssh2.dll
  • libssl-1_1.dll
  • libssl-1_1-x64.dll
  • nghttp2.dll
  • libeay32.dll (if existing in your PHP distribution)
  • ssleay32.dll (if existing in your PHP distribution)

from the PHP root folder to the Apache2/bin folder, in case you 're confident that the PHP build is newer than the Apache build.

In the opposite case, you can copy the same files from the Apache BIN to the PHP root.

In any case, backup the contents of the APache and PHP folders beforehand.

Adding the PHP path as an enviromental variable will give priority to this path for loading the relevant DLLs and may solve the problem. However, you lose in server portability. Additionally, if you have also added the Apache PATH as a variable and the OpenSSL versions are way different (up to loading different linked DLL files), a lot of shit may happen.

1
  • 1
    I had to copy over libssl-1_1.dll and libcrypto-1_1.dll from my php7.2.8/ext folder to apache2.4.23/bin folder to get this to work. Before that, I was receiving "Unable to load dynamic library" on php_curl.dll and php_openssl.dll desipite those files existing in the correct place. Jul 28, 2018 at 5:34
2

Make sure to have your apache SSH dlls loading correctly. On a fresh install I had to download and load into my apache bin directory the following dll "libssh2.dll"

After ssl dll was loaded cURL was able to load with no issues.

You can download it from the link below:

http://windows.php.net/downloads/pecl/releases/ssh2/0.12/

1
  • Copying this library from php bin to apache bin directory is what worked for me.
    – Toby Allen
    Oct 13, 2015 at 8:29
2

Solution:

Step1: Uncomment the php_curl.dll from php.ini

Step2: Copy the following three files from php installed directory.i.e "C:\\php7".

libeay32.dll,
libssh2.dll,
ssleay32.dll

Step3: Paste the files under two place

httpd.conf's ServerRoot directive. i.e "C\Apache24"
apache bin directory. i.e "C\Apache24\bin"

Step4: Restart apache.

That's all. I solve the problem by this way.Hope it might work for you.

The solution is given here. https://abcofcomputing.blogspot.com/2017/06/php7-unable-to-load-phpcurldll.html

2

After having tried everything here I had to simply upgrade Apache to a newer version in order to make curl extension work.

I was upgrading PHP from 7.0.2 to 7.1.15 after which curl did not work. Only way to fix it was upgrade Apache (which was version 2.4.18) to the latest 2.4.29.

Didn't have to copy any of the lib/ssleay dll files to either Apache or Windows - possibly because I already have the PHP folder in my system path.

Running Windows 10, 64-bit, thread-safe versions, VC14.

2

Insert to file httpd.conf

LoadFile "D:/DevKit/PHP7.1/libeay32.dll"
LoadFile "D:/DevKit/PHP7.1/libssh2.dll"
LoadFile "D:/DevKit/PHP7.1/ssleay32.dll"
1
  • Before I updated my PHP version to 7.4.0 RC4, the method provided by @Jpsy above solved the problem. After the update, your method solved the problem. Thanks.
    – Ian Y.
    Nov 17, 2019 at 11:47
2

In php.ini you must put the extension_dir static path. extension_dir = "C:\laragon\bin\php\php-7.3.11-Win32-VC15-x64\ext" by example. Don't forget to remove the semicolon before this variable.

0

I have encountered the same problem before.I resolved it by add php directory to windows system environment variables---Path.

0

I got this error because, on my system at least, if extension_dir in php.ini is set to a relative path, it is taken as being relative to the root Apache directory, so to get it to point to the correct directory I had to use an absolute path: "C:\Program Files (x86)\PHP\ext". (This was PHP 5.5.31 and Apache 2.4.23 on Windows 10; setting extension_dir to ext worked just fine with the same setup on Windows 7. I first got it to work by putting an ext directory in the Apache folder with the necessary dlls, then figured out what was happening.)

It was also necessary to set the PATH correctly or make sure the dlls mentioned above (libeay32.dll, libssh2.dll, and ssleay32.dll) are in Apache's bin directory (or most likely any of the places other answers mention). The fact that I got the same error message for Apache not being able to find lib_curl.dll as for it not being able to find libssh2.dll did not make things any easier to figure out.

0

Add your php folder path to the System PATH and everything should work fine. It will also fix some other extensions that are broken.

0

Maybe not the best approach, but it definitely works. (2019-2022)

"Your install of PHP does not have the 'php_curl.dll' extension enabled."

  1. find "php.ini", if no you have to rename "php.ini-development" to "phh.ini". Open it.

  2. find ;extension_dir = "ext"

  3. add these under that line, there is no ";"

extension_dir = "[php dir]\ext"
extension=php_curl.dll
0

The most proper and cleanest way seems to be using FileLoad directive.

I do have multiple Apache-PHP sets on a PC. Setting a PATH to one PHP dir, creates problems in the other PHP version.

Of course I don't want to copy dll files nowhere.

I just needed one file: libssh2.dll
I did add it into a IfModule directive's enclosure:

# PHP7 module
LoadModule php7_module "../../../PHP/App/v7.3.1/php7apache2_4.dll"
<IfModule php7_module>
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
    PHPIniDir "../../../PHP/App/v7.3.1"
    LoadFile "../../../PHP/App/v7.3.1/libssh2.dll"
</IfModule>

I can have a separate conf file with PHP directives for specific PHP versions and choose which to include at httpd start time.

LoadFile is also suggested in @BlitZ comment under one of the answers.
And later in @Leon Lam answer.

-1

its caused from apache server version download apache server fresh : https://www.apachelounge.com/download/VS17/binaries/httpd-2.4.58-240131-win64-VS17.zip

replace address to previus version.

in laragon +> D:\Dev\laragon\bin\apache change

httpd-2.4.54-win64-VS16 <+ old one

httpd-2.4.58-win64-VS16 <+ New one

1
  • 2
    Welcome to StackOverflow. Please, edit and try for How to Answer, describe the effect of what you propose and explain why it helps to solve the problem.
    – Yunnosch
    Mar 17 at 20:30

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