PHP unable to load php_curl.dll extension
Asked Answered
A

16

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.

Antisocial answered 7/5, 2013 at 16:31 Comment(8)
possible duplicate of Enabling cURL with PHPBronez
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 thanksBrookbrooke
Same problem, but no answer on that threadAntisocial
I installed PHP and Apache using their individual packages. I'll edit my post to reflect that. Thanks for the response though!Antisocial
ok edit your question to not include the other tools just say clean install no 3rd party program usedBrookbrooke
@Antisocial - have you tried the fixed php_curl.dll from mediafire.com/?3ay381k3cq59cm2 ?Brookbrooke
Yep I've looked at it already. I'm running x86 PHP and all the fixed php_curl.dll's are 64 bit.Antisocial
This question is still relevant to Apache 2.4.x (.27) and PHP 7.1.x (.9) and will no doubt continue to be until, if ever, the relevant common DLLs are shipped with version number as part of the filename...Strudel
K
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!

Kunlun answered 14/10, 2014 at 19:3 Comment(23)
This was what finally worked for me - no custom dll nonsense required.Shoifet
Adding the PHP directory to the PATH variable was the thing to do in my case. Thanks.Agential
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.Steelyard
Applied just now, Windows 10, WAMP 2.5, PHP 7.0.2. Thank youNorm
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.Amalea
@Amalea did you restart or did you do a full stop and start? See comment of Sean256 above.Kunlun
Restart was definitely required. Using PHP 5.6.27 EasyPHP Win10.Cyclopropane
#41107856Tributary
FWIW, having php on the path was insufficient for me running php 7.1.5 and Apache 2.4.10. I needed to update the files in the apache bin dir. I perhaps oughta update Apache (it's up to 2.4.25 at time of writing), and see if the versions of those DLLs it ships with are sufficient. Obvs I'd rather not be mix 'n' matching DLLs like this, but equally I don't wanna be messed around too much on this which is just a dev machine anyhow.Woods
Hi @AdamCameron, your problem was most likely the result of the Apache path being stored in the Path variable too. I updated my answer so that the PHP path is prepended instead of appended. This makes sure that the DLLs in the PHP path are used and not any other versions that may exist in other paths of the system.Kunlun
Hi @Kunlun nah, don't have Apache in the path. Not to worry. I've got some spare time today so I might roll back this change, update Apache to be current, and see if the problem still persists (and will report back).Woods
Ah! Thank you! It worked for me. I had environment variable to a different version of PHPAgneta
On Windows 10 you do need to reboot after changing the PATH variable (which I'm pretty sure was never necessary with Windows 7). It's called 'progress' :/ (I had Perforce with these DLLs in the path ahead of PHP which was causing the issue; Perforce seems to be ok with the change.)Strudel
After a lot of search, finally it works when I add path in envirment variable and delete those dll files from apache/bin.Tributary
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.Hobbema
@EdmundTam : Thanks for the feedback! I have updated the answer to make sure, other users do not fall into this nasty trap.Kunlun
It worked when I copy libssh2.dll from PHP folder to Apache bin folder, ssleay32.dll and libeay32.dll was already there.Breach
@Breach did you read my answer at all? What you did is a solution that may come back to bite you.Kunlun
@Kunlun Thank you for the warning, but it didn't work even my PHP is added to PATH, so copying libssh2.dll to Apache's bin folder was the only solution for me. As I manually installed Apache & PHP from their zip archive and no use installers, I'll delete whole content of the folder and extract the newer versions from scratch, updating them will not be an issue (I hope :) )Breach
Can confirm this answer worked 100% for me with new WAMP 3.1.9 install. PHP - 7.2.18, Apache 2.4.39Dingle
Can confirm this answer worked 100% with PHP 7.4. Remember step 4! Turn off Apache COMPLETELY and start overBoltrope
One important note @Jpsy: setting path to "C:\Program Files\PHP" does not work. You have to use short syntax without spaces: "C:\Progra~1\PHP". I lost 3 hours trying to resolve this...Headrest
@Headrest this is interesting. I guess it is more related to the blank in the path than to the long filename format itself. I have added your suggestion to the answer. Many thanks for this important detail!Kunlun
S
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

Sailor answered 12/6, 2015 at 19:53 Comment(7)
Just copying the libssh2.dll file to Apache24\bin worked.. thanks! so weird o.OSeedling
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.Klehm
don't need to copy libssh2.dll to apacheObregon
@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.Tributary
copying libssh2.dll file to Apache24\bin worked for me tooRoden
It worked when I copy libssh2.dll from PHP folder to Apache bin folder, ssleay32.dll and libeay32.dll was already there.Breach
Did not work for me... :( Those files in bin are symlinks on my Windows. No need for copying them, in any case.Petrochemistry
D
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.

Dispensatory answered 20/12, 2015 at 13:58 Comment(9)
I had to place the dlls in apache's bin dir (and replace the existing ones) to make it work.Ulrich
Yup, putting these files from my PHP directory into Apache24/bin and restarting Apache worked for me. Thanks!Neuroglia
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.Kunlun
@Kunlun you are talking about VirtualHost Directory which is different than ServerRoot path. VirtualHosts have same ServerRoot and different Directory.Dispensatory
Oh yes, my fault. I mixed up ServerRoot and DocumentRoot. Sorry.Kunlun
I deleted the dll in apache/bin to make it work. The old dll from the last php version blocked windows from using the new dll in php folder. I had globale path set as described in the accepted answerCoagulate
#41107856Tributary
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.Mapp
I found a better solution on github by adding LoadFile "C:/php/libssh2.dll" and LoadFile "C:/php/libsqlite3.dll" to the httpd.config file of apache. Where C:/php is replaced by your php directory ofcourse. gist.github.com/alecos71/de26b0079b963a690e798375b8561dfaPepi
T
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

Talipes answered 7/5, 2013 at 16:36 Comment(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. #10939748Talipes
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.Antisocial
I do not think you need to do that. Did you copy dependencies to apache/bin as well?Talipes
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.Antisocial
@Antisocial 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! :-)Talipes
This worked for my (last part of copying the dll to bin folder. I was upgrading php5.6 to php7 somehow the old dll inside my apache/bin folder was not compatibleWheal
T
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.

Tamie answered 11/7, 2018 at 14:13 Comment(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.Sayyid
L
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/

Legend answered 12/6, 2015 at 17:40 Comment(1)
Copying this library from php bin to apache bin directory is what worked for me.Tindall
R
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

Rattail answered 28/6, 2017 at 8:42 Comment(0)
W
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.

Weigel answered 5/3, 2018 at 11:1 Comment(0)
T
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"
Thaumatrope answered 28/3, 2018 at 19:46 Comment(1)
Before I updated my PHP version to 7.4.0 RC4, the method provided by @Kunlun above solved the problem. After the update, your method solved the problem. Thanks.Payroll
H
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.

Heelandtoe answered 28/10, 2019 at 20:33 Comment(0)
S
0

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

Symon answered 21/12, 2016 at 9:39 Comment(0)
K
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.

Khalid answered 6/1, 2017 at 2:23 Comment(0)
A
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.

Alcaide answered 4/2, 2017 at 14:13 Comment(0)
S
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
Smiga answered 16/3, 2022 at 9:4 Comment(0)
C
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.

Cottony answered 2/7, 2023 at 0:23 Comment(0)
S
-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

Screech answered 17/3 at 20:25 Comment(1)
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.Calumny

© 2022 - 2024 — McMap. All rights reserved.