[英]PHP unable to load php_curl.dll extension
Follow-up from my post yesterday ( Enabling cURL with PHP )跟进我昨天的帖子( 启用 cURL 和 PHP )
The problem is that PHP isn't able to load php_curl.dll.问题是 PHP 无法加载 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.我已经尝试了几个步骤,包括取消注释
extension=php_curl.dll
,确保依赖项libeay32.dll
和ssleay32.dll
eixst 在路径中,重新下载 php_curl.dll,替换旧的,最后复制到我的 System32 文件文件夹。
I'm using Apache 2.2 and PHP 5.4.14.我正在使用 Apache 2.2 和 PHP 5.4.14。 I installed both using their individual packages;
我使用它们各自的包安装了它们; I'm not using XAMP or WAMP.
我没有使用 XAMP 或 WAMP。 I'm using Windows 7 64-bit.
我正在使用 Windows 7 64 位。
Any help at all would be appreciated.任何帮助都将不胜感激。
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 的
ServerRoot
、Apache 的\\bin\\
、Window 的\\System32\\
,或者更糟的是复制到 Windows 主目录中是一个糟糕的技巧,甚至可能不适用于较新的 PHP 版本。
The right way to do it is to add the PHP path to the Windows Path
variable.正确的做法是将 PHP 路径添加到 Windows
Path
变量中。
Control Panel -> System
click on Advanced System Settings or press WIN + R and type SystemPropertiesAdvanced
Control Panel -> System
单击高级系统设置或按WIN + R并键入SystemPropertiesAdvanced
Path
variable.Path
变量。 Edit it and prepend C:\\PHP;
C:\\PHP;
to it - or whatever the path to your PHP folder is.C:\\Program Files\\PHP
you may need to use the short filename form here, ie C:\\Progra~1\\PHP
.) C:\\Program Files\\PHP
这样的空格,您可能需要在此处使用短文件名形式,即C:\\Progra~1\\PHP
。) Update 2017-05: 2017-05 更新:
I changed the instructions above to prepend the Path variable with the PHP path instead of appending to it.我更改了上面的说明,在 Path 变量前面加上PHP 路径而不是附加到它。 This makes sure that the DLLs in the PHP path are used and not any other (outdated) versions in other paths of the system.
这可确保使用 PHP 路径中的 DLL 而不是系统其他路径中的任何其他(过时)版本。
Update 2018-04: 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!如果您已经选择了错误的方式并将任何 PHP DLL 复制到 Apache 或 Windows 路径,那么我强烈建议您再次删除它们! If you don't, you might get into trouble when you later try to update PHP.
如果不这样做,则在以后尝试更新 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.
如果新的 PHP 版本带来了这些 DLL 的新版本,但您的旧 DLL 仍然存在于系统或 Web 服务器路径中,则可能首先找到这些旧 DLL。 This will most certainly prevent the PHP interpreter from starting.
这肯定会阻止 PHP 解释器启动。 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.
所以最好现在清理并从 Windows 和 Apache 路径中删除任何提到的 DLL,如果您将它们复制到那里。
(Thanks to @EdmundTam and @WasimA. for pointing out this problem in the comments!) (感谢@EdmundTam 和@WasimA。在评论中指出了这个问题!)
Update 2019-10: 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:提示:要查找这些 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: 的整个目录结构。
Update 2020-08: 2020-08 更新:
If your PHP folder contains spaces (ie C:\\Program Files\\PHP
) you may need to use the short filename form in the Path
variable at step 3 (ie C:\\Progra~1\\PHP
).如果您的 PHP 文件夹包含空格(即
C:\\Program Files\\PHP
),您可能需要在步骤 3 的Path
变量中使用短文件名形式(即C:\\Progra~1\\PHP
)。 Thanks to @onee for this tip!感谢@onee 的提示!
In PHP 5.6.x version You should do the following:在 PHP 5.6.x 版本中,您应该执行以下操作:
Move to Windows\\system32
folder DLLs from php
folder:从
php
文件夹移动到Windows\\system32
文件夹 DLL:
libssh2.dll, ssleay32.dll, libeay32.dll
and php_curl.dll
from php ext
folder来自
php ext
文件夹的libssh2.dll, ssleay32.dll, libeay32.dll
和php_curl.dll
Move to Apache24\\bin
folder from php
folder:从
php
文件夹移动到Apache24\\bin
文件夹:
libssh2.dll
Also, don't forget to uncomment extension=php_curl.dll
in php.ini
另外,不要忘记在
php.ini
取消注释extension=php_curl.dll
Solution: Put libeay32.dll
, libssh2.dll
, ssleay32.dll
files under dir specified in httpd.conf
's ServerRoot directive.解决方案:将
libeay32.dll
、 libssh2.dll
、 ssleay32.dll
文件放在httpd.conf
的 ServerRoot 指令中指定的目录下。 These dlls can be found compiled under php root folder.这些 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_curl.dll
需要在加载时访问以下库: libeay32.dll
、 libssh2.dll
、 ssleay32.dll
并且如果你把它们放在 . /php/ext
dir or if you put PHP extensions in PHP root dir. /php/ext
dir 或者如果您将 PHP 扩展放在 PHP 根目录中。
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:当然,您可以将它们放在
C:\\Windows
或 PATH 中定义的某些全局文件夹中,但是如果您不想这样做并且希望您的 apache+php 安装是可移植的:
The path specified in ServerRoot
in httpd.conf
is treated as home path for php. httpd.conf
中ServerRoot
中指定的路径被视为 php 的主路径。 The behaviour is similar to situation where you include .该行为类似于您包含 .
/path/to/some.php
file in . /path/to/some.php
文件在 . /index.php
and home path for some.php
file is still . /index.php
和some.php
文件的主路径仍然是 . /
the dir where index.php
resides. /
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. php_curl.dll
只需将这三个 dll 放在您在httpd.conf
ServerRoot 指令中指定的目录中, php_curl.dll
将不会再次加载失败。
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()
首先通过运行
phpinfo()
检查您使用的是哪个php.ini
文件
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.接下来确保
php_curl.dll
存在于该文件夹中。 If not copy it over.如果没有复制过来。
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
将
php_installation_folder/extensions
的 dll 文件复制到apache_installation_folder/bin
Usually this is an OpenSSL version mismatch error, between Apache and PHP.通常这是 Apache 和 PHP 之间的 OpenSSL 版本不匹配错误。 In case Apache loads PHP as a DSO module, its own OpenSSL versions (dlls and libs) will be used.
如果 Apache 将 PHP 作为 DSO 模块加载,则将使用其自己的 OpenSSL 版本(dll 和库)。 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.
因此,如果 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.由于您需要加载 PHP 扩展,因此您需要相关的 DLL 文件至少是 PHP 模块要求的版本。 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:
假设您正在使用 Apache 和 PHP 的最新版本,并且都使用相同的 MVC 版本构建,您可以复制以下文件:
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.将PHP路径添加为环境变量会优先使用该路径加载相关DLL,可能会解决问题。 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.
此外,如果您还添加了 Apache PATH 作为变量,并且 OpenSSL 版本有很大不同(取决于加载不同的链接 DLL 文件),那么可能会发生很多事情。
Make sure to have your apache SSH dlls loading correctly.确保您的 apache SSH dll 正确加载。 On a fresh install I had to download and load into my apache bin directory the following dll "libssh2.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:您可以从以下链接下载:
http://windows.php.net/downloads/pecl/releases/ssh2/0.12/ http://windows.php.net/downloads/pecl/releases/ssh2/0.12/
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
After having tried everything here I had to simply upgrade Apache to a newer version in 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.我正在将 PHP 从 7.0.2 升级到 7.1.15,之后
curl
不起作用。 Only way to fix it was upgrade Apache (which was version 2.4.18) to the latest 2.4.29.修复它的唯一方法是将 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。
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"
In php.ini you must put the extension_dir static path.在 php.ini 中,您必须放置 extension_dir 静态路径。
extension_dir = "C:\\laragon\\bin\\php\\php-7.3.11-Win32-VC15-x64\\ext"
by example. extension_dir = "C:\\laragon\\bin\\php\\php-7.3.11-Win32-VC15-x64\\ext"
举例。 Don't forget to remove the semicolon before this variable.不要忘记删除此变量前的分号。
我之前也遇到过同样的问题,我通过在windows系统环境变量---路径中添加php目录解决了。
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"
.我收到此错误是因为,至少在我的系统上,如果 php.ini 中的
extension_dir
设置为相对路径,则它被视为相对于根 Apache 目录,因此要使其指向正确的目录,我必须使用绝对路径: "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.) (这是 Windows 10 上的 PHP 5.5.31 和 Apache 2.4.23;将
extension_dir
设置为ext
在 Windows 7 上使用相同的设置工作得很好。我首先通过在 Apache 文件夹中放置一个包含必要 dll 的 ext 目录来使其工作,然后弄清楚发生了什么。)
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).还需要正确设置 PATH 或确保上面提到的 dll(libeay32.dll、libssh2.dll 和 ssleay32.dll)位于 Apache 的 bin 目录中(或者很可能是其他答案提到的任何地方)。 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.
事实上,我收到了同样的错误消息,因为 Apache 无法找到 lib_curl.dll,因为它无法找到 libssh2.dll,这并没有让事情变得更容易弄清楚。
Add your php folder path to the System PATH and everything should work fine.将您的 php 文件夹路径添加到系统路径,一切都应该正常工作。 It will also fix some other extensions that are broken.
它还将修复一些其他损坏的扩展。
Maybe not the best approach, but it definitely works.也许不是最好的方法,但它绝对有效。 (2019-2022)
(2019-2022)
"Your install of PHP does not have the 'php_curl.dll' extension enabled." “您安装的 PHP 没有启用‘php_curl.dll’扩展。”
find "php.ini", if no you have to rename "php.ini-development" to "phh.ini".找到“php.ini”,如果没有,你必须将“php.ini-development”重命名为“phh.ini”。 Open it.
打开它。
find;extension_dir = "ext"查找;extension_dir =“分机”
add these under that line, there is no ";"在该行下添加这些,没有“;”
extension_dir = "[php dir]\ext"
extension=php_curl.dll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.