PHP 无法加载 php_curl.dll 扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16424117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP unable to load php_curl.dll extension
提问by user2066880
Follow-up from my post yesterday (Enabling cURL with PHP)
昨天我的帖子的后续(使用 PHP 启用 cURL)
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.
问题是 PHP 无法加载 php_curl.dll。我尝试了几个步骤,包括取消注释extension=php_curl.dll
,确保路径中的依赖项libeay32.dll
和ssleay32.dll
eixst,重新下载 php_curl.dll,替换旧的,最后将文件复制到我的 System32 文件夹中。
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.
我使用的是 Apache 2.2 和 PHP 5.4.14。我使用各自的软件包安装了它们;我没有使用 XAMP 或 WAMP。我正在使用 Windows 7 64 位。
Any help at all would be appreciated.
任何帮助都将不胜感激。
回答by Jpsy
libeay32.dll
and ssleay32.dll
have to be path-accessible for php_curl.dll
loading to succeed.
libeay32.dll
并且ssleay32.dll
必须是路径可访问的php_curl.dll
才能成功加载。
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.
但是将它们复制到 Apache's ServerRoot
、 Apache's \bin\
、 Window's \System32\
,甚至更糟的 Windows 主目录中是一个糟糕的黑客,甚至可能不适用于较新的 PHP 版本。
The right way to do it is to add the PHP path to the Windows Path
variable.
正确的做法是将 PHP 路径添加到 WindowsPath
变量中。
- In
Control Panel -> System
click on Advanced System Settingsor press WIN+Rand typeSystemPropertiesAdvanced
- Click the button Environment Variables.
- Under System Variablesyou will find the
Path
variable. Edit it and prependC:\PHP;
to it - or whatever the path to your PHP folder is. - Then fully stop Apache and start it again (a simple restart might not be enough).
- 在
Control Panel -> System
单击高级系统设置或按WIN+R并键入SystemPropertiesAdvanced
- 单击按钮环境变量。
- 在系统变量下,您将找到该
Path
变量。编辑它并添加C:\PHP;
到它 - 或者你的 PHP 文件夹的任何路径。 - 然后完全停止 Apache 并再次启动它(简单的重启可能还不够)。
Update 2017-05:
I changed the instructions above to prependthe Path variable with the PHP path instead of appendingto 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.
2017-05 更新:
我更改了上面的说明,在 Path 变量前面加上PHP 路径,而不是附加到它。这确保使用 PHP 路径中的 DLL 而不是系统其他路径中的任何其他(过时)版本。
Update 2018-04:
If you have alreadychosen 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 nowand 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!)
2018-04 更新:
如果您已经选择了错误的方式并将任何 PHP DLL 复制到 Apache 或 Windows 路径,那么我强烈建议您再次删除它们!如果不这样做,则在以后尝试更新 PHP 时可能会遇到麻烦。如果新的 PHP 版本带来了这些 DLL 的新版本,但您的旧 DLL 仍然在系统或 Web 服务器路径中徘徊,则可能首先找到这些旧 DLL。这肯定会阻止 PHP 解释器启动。此类错误可能很难理解和解决。所以最好现在清理并从 Windows 和 Apache 路径中删除任何提到的 DLL,如果您将它们复制到那里。
(感谢@EdmundTam 和@WasimA。在评论中指出了这个问题!)
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:
2019-10 更新:
提示:要查找这些 DLL 的所有副本并检查您是否将它们放在错误的文件夹中,您可以在 Windows 命令提示符窗口中使用以下命令:
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:.
请注意,这些命令可能需要一些时间才能完成,因为它们会搜索系统驱动器 C: 的整个目录结构。
回答by Matt
In PHP 5.6.x version You should do the following:
在 PHP 5.6.x 版本中,您应该执行以下操作:
Move to Windows\system32
folder DLLs from php
folder:
Windows\system32
从php
文件夹移动到文件夹 DLL :
libssh2.dll, ssleay32.dll, libeay32.dll
and php_curl.dll
from php ext
folder
libssh2.dll, ssleay32.dll, libeay32.dll
并php_curl.dll
从php ext
文件夹
Move to Apache24\bin
folder from php
folder:
Apache24\bin
从php
文件夹移动到文件夹:
libssh2.dll
Also, don't forget to uncomment extension=php_curl.dll
in php.ini
另外,不要忘了取消注释extension=php_curl.dll
中php.ini
回答by BIOHAZARD
WINDOWS Apache 2.4.x + PHP 7.0.x SOLUTION HERE:
WINDOWS Apache 2.4.x + PHP 7.0.x 解决方案在这里:
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.
解决方案:将 libeay32.dll、libssh2.dll、ssleay32.dll 文件放在 httpd.conf 的 ServerRoot 指令中指定的目录下。这些 dll 可以在 php 根文件夹下找到。
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.
问题是 php_curl.dll 需要在加载时访问以下库:libeay32.dll、libssh2.dll、ssleay32.dll,如果将它们放在 ./php/ext 目录中或将 php 扩展名放在 php root 中,则没有意义目录
Of course you can put them in c:\Windows or in some global folder defined in PATH but if you dont want to do this and you want that your apache+php installation was portable:
当然,您可以将它们放在 c:\Windows 或 PATH 中定义的某个全局文件夹中,但是如果您不想这样做并且希望您的 apache+php 安装是可移植的:
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.
httpd.conf 中 ServerRoot 中指定的路径被视为 php 的主路径。该行为类似于您在 ./index.php 中包含 ./path/to/some.php 文件并且 some.php 文件的主路径仍然是 ./ index.php 所在的目录的情况。
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.
简而言之,只需将这三个 dll 放在您在 httpd.conf ServerRoot 指令中指定的目录中,php_curl.dll 将不会再次加载失败。
回答by raidenace
You are loading .dll
so your OS has to be windows.
您正在加载,.dll
因此您的操作系统必须是 Windows。
First check which php.ini
file you are using by running phpinfo()
首先php.ini
通过运行检查您正在使用的文件phpinfo()
Then check where your extensions folder is by checking extension_dir
attribute in that file.
然后通过检查extension_dir
该文件中的属性来检查扩展文件夹的位置。
Next make sure that php_curl.dll
is present in that folder. If not copy it over.
接下来确保php_curl.dll
存在于该文件夹中。如果没有复制过来。
Restart apache
and check if it works.
重新启动apache
并检查它是否有效。
Since you installed packages individually, also do this:
由于您单独安装了软件包,请执行以下操作:
Copy the dll file from php_installation_folder/extensions
to apache_installation_folder/bin
将dll文件复制php_installation_folder/extensions
到apache_installation_folder/bin
回答by Chris Tsirkas
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.
通常这是 Apache 和 PHP 之间的 OpenSSL 版本不匹配错误。如果 Apache 将 PHP 作为 DSO 模块加载,则将使用其自己的 OpenSSL 版本(dll 和库)。因此,如果 PHP 扩展需要更新的版本,它可能无法在 Apache 加载的 DLLS 中找到合适的接口并且无法工作。
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:
由于您需要加载 PHP 扩展,因此您需要相关的 DLL 文件至少是 PHP 模块要求的版本。假设您正在使用 Apache 和 PHP 的最新版本,并且都使用相同的 MVC 版本构建,您可以复制以下文件:
- 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)
- libcrypto-1_1.dll
- libcrypto-1_1-x64.dll
- 库文件
- 库文件
- libssh2.dll
- libssl-1_1.dll
- libssl-1_1-x64.dll
- nghttp2.dll
- libeay32.dll(如果存在于您的 PHP 发行版中)
- ssleay32.dll(如果存在于您的 PHP 发行版中)
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.
从 PHP 根文件夹到 Apache2/bin 文件夹,以防您确信 PHP 版本比 Apache 版本新。
In the opposite case, you can copy the same files from the Apache BIN to the PHP root.
在相反的情况下,您可以将相同的文件从 Apache BIN 复制到 PHP 根目录。
In any case, backup the contents of the APache and PHP folders beforehand.
无论如何,请事先备份APache 和PHP 文件夹的内容。
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.
将PHP路径添加为环境变量会优先使用该路径加载相关DLL,可能会解决问题。但是,您会失去服务器的可移植性。此外,如果您还添加了 Apache PATH 作为变量,并且 OpenSSL 版本有很大不同(取决于加载不同的链接 DLL 文件),那么可能会发生很多事情。
回答by shafiq2410
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
这里给出了解决方案。 https://abcofcomputing.blogspot.com/2017/06/php7-unable-to-load-phpcurldll.html
回答by TheStoryCoder
After having tried everything here I had to simply upgrade Apache to a newer versionin order to make curl
extension work.
在尝试了这里的一切之后,我不得不简单地将 Apache 升级到更新的版本,以便curl
扩展工作。
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.
我正在将 PHP 从 7.0.2 升级到 7.1.15,之后curl
没有用。修复它的唯一方法是将 Apache(版本 2.4.18)升级到最新的 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.
不必将任何 lib/ssleay dll 文件复制到 Apache 或 Windows - 可能是因为我的系统路径中已经有 PHP 文件夹。
Running Windows 10, 64-bit, thread-safe versions, VC14.
运行 Windows 10、64 位、线程安全版本、VC14。
回答by Leon Lam
Insert to file httpd.conf
插入到文件 httpd.conf
LoadFile "D:/DevKit/PHP7.1/libeay32.dll"
LoadFile "D:/DevKit/PHP7.1/libssh2.dll"
LoadFile "D:/DevKit/PHP7.1/ssleay32.dll"
回答by Alan D
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"
确保您的 apache SSH dll 正确加载。在全新安装时,我必须下载以下 dll“libssh2.dll”并将其加载到我的 apache bin 目录中
After ssl dll was loaded cURL was able to load with no issues.
加载 ssl dll 后,cURL 能够正常加载。
You can download it from the link below:
您可以从以下链接下载:
回答by Wendinmi
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.
在 php.ini 中,您必须放置 extension_dir 静态路径。extension_dir = "C:\laragon\bin\php\php-7.3.11-Win32-VC15-x64\ext"
举个例子。不要忘记删除此变量前的分号。