简体   繁体   English

如何让CURL在Windows上与PHP一起使用? (WAMP)

[英]How to get CURL to work with PHP on Windows? (WAMP)

Update : The problem appears to have been corrupt DLLs somewhere in my PHP installation, or possibly a bug in PHP 5.2.9 on Win2k. 更新 :问题似乎是我的PHP安装中的某个地方已损坏的DLL,或者可能是Win2k上的PHP 5.2.9中的错误。 I downloaded the windows (binaries-only) distribution of PHP 5.2.10 from php.net and extracted that to my c:\\PHP directory. 我从php.net下载了PHP 5.2.10的windows(仅限二进制文件)发行版,并将其解压缩到我的c:\\ PHP目录中。 After doing that, everything worked fine. 在这之后,一切都很好。

Update2 : I undid everything that I tried earlier (everything from the bulleted list below), except that I left " extension=php_curl.dll " uncommented in my php.ini file. Update2 :我解除了我之前尝试的所有内容(以下项目符号列表中的所有内容), 除了我在php.ini文件中取消注释“ extension=php_curl.dll ”。 It turns out that is all you should have to do in a proper installation. 事实证明,在正确的安装中你应该做的就是这一切。


I'm trying to get CURL to work on a Windows installation of PHP (version 5.2.9-2), and I am at wit's end. 我正在尝试让CURL在PHP的Windows安装(版本5.2.9-2)上工作,而我现在已经结束了。 I have found the PHP CURL installation page , this SO question which references this page , and this SO question . 我找到了PHP CURL安装页面这个SO问题引用了这个页面这个问题 I've tried most of the suggestions in all of those pages but I still get an error. 我已经在所有这些页面中尝试了大部分建议,但我仍然遇到错误。 Here is my very simple test page: 这是我非常简单的测试页面:

<?php
$ch = curl_init();
?>
<b>Success!</b>

This gives me: 这给了我:

Fatal error : Call to undefined function curl_init() in C:\\ApacheRoot\\curltest.php on line 2 致命错误 :在第2行的C:\\ ApacheRoot \\ curltest.php中调用未定义的函数curl_init()

In my Apache error log I get this each time the server starts: 在我的Apache错误日志中,每次服务器启动时都会收到:

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\\\PHP\\\\ext\\\\php_curl.dll' - The specified procedure could not be found.\\r\\n in Unknown on line 0

I have done the following: 我做了以下事情:

  • Uncommented the following line in php.ini: extension=php_curl.dll 取消注释php.ini中的以下行: extension=php_curl.dll
  • Copied ssleay32.dll and libeay32.dll from C:\\PHP to C:\\WINNT\\System32 ssleay32.dlllibeay32.dll从C:\\ PHP复制到C:\\ WINNT \\ System32
  • Downloaded cURL for Win32 from curl.haxx.se and extracted the .zip file to C:\\cURL curl.haxx.se下载了Win32的cURL并将.zip文件解压缩到C:\\ cURL
  • Added C:\\cURL to my system PATH environment variable. C:\\cURL添加到我的系统PATH环境变量中。
  • Verified that: 验证:
    • php.ini includes extension_dir="C:\\PHP\\ext" php.ini包含extension_dir="C:\\PHP\\ext"
    • The directory C:\\PHP\\ext contains php_curl.dll 目录C:\\PHP\\ext包含php_curl.dll
    • The only php.ini file on my system is in C:\\PHP (ie especially that there is no C:\\WINNT\\php.ini ) 我系统上唯一的php.ini文件是C:\\PHP (特别是没有C:\\WINNT\\php.ini
    • The Apache httpd.conf file includes the line PHPIniDir "C:/PHP/" Apache httpd.conf文件包含PHPIniDir "C:/PHP/"

I have also rebooted the machine (several times, in fact...). 我也重新启动了机器(好几次,实际上......)。

You don't have to reboot the computer, just restart the apache and the php module will read the new ini. 您不必重新启动计算机,只需重新启动Apache,php模块将读取新的ini。
Did you change the correct php.ini? 你有没有改变正确的php.ini? In case of doubt 如有疑问

<?php echo 'php.ini: ', get_cfg_var('cfg_file_path'); ?>

can tell you. 可以告诉你。

Is there something in the error.log of the apache that indicates that something went wrong while loading php and the php_curl.dll? apache的error.log中是否有东西表明在加载php和php_curl.dll时出现了问题?

Did you start the apache as a win32 service? 你是否以win32服务启动了apache? If you did try to start it as a console application. 如果您尝试将其作为控制台应用程序启动。 Error messages will show up on the console then. 然后,错误消息将显示在控制台上。 Or start it as a service and take a look at the error.log file and the windows event log (start, run, eventvwr.msc /s ). 或者将其作为服务启动并查看error.log文件 Windows事件日志(start,run, eventvwr.msc /s )。

edit: 编辑:
"The specified procedure could not be found" “无法找到指定的程序”
You need a dll that is compatible with your php version and build. 你需要一个兼容你的php版本和构建的DLL。 Exactly what did you install and where did you get it from? 究竟你安装了什么,你从哪里得到它?

Try this: 尝试这个:

  1. Stop WAMP completely. 完全停止WAMP。
  2. Find your WAMP folder: C:\\Path\\To\\WAMP\\bin\\Apache\\ApacheVersion\\bin\\ 找到您的WAMP文件夹:C:\\ Path \\ To \\ WAMP \\ bin \\ Apache \\ ApacheVersion \\ bin \\
  3. Edit that php.ini and uncomment extension=php_curl.dll 编辑php.ini并取消注释extension = php_curl.dll
  4. Restart WAMP. 重启WAMP。

That should hopefully solve it. 这应该有希望解决它。

*EDIT : Do the same thing @ C:\\Path\\To\\WAMP\\bin\\php\\PHPVersion\\ *编辑 :做同样的事情@ C:\\ Path \\ To \\ WAMP \\ bin \\ php \\ PHPVersion \\

This is what worked for me 这对我有用

Answered by Soren from another SO thread - CURL for WAMP Soren从另一个SO线程回答 - CURL for WAMP

"There seems to be a bug somewhere. If you are experiencing this on Win 7 64 bit then try installing apache addon version 2.2.9 and php addon version 5.3.1 and switching to those in WAMP and then activating the CURL extension. That worked for me." “某处似乎有一个错误。如果你在Win 7 64位上遇到这个问题,那么尝试安装apache addon版本2.2.9和php插件版本5.3.1并切换到WAMP中的那些然后激活CURL扩展。为了我。”

This fixed it for me: 这为我修好了:

Go to here: 去这里:

http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/ http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

Download 'php_curl-5.3.13-VC9-x64.zip' 下载'php_curl-5.3.13-VC9-x64.zip'

Stop WAMP Server from Running 阻止WAMP服务器运行

Extract the file 'php_curl.dll'. 解压缩文件'php_curl.dll'。

On your local machine, browse to (or where your WAMP installation is found) c:\\wamp\\bin\\php\\php5.3.13\\ext 在本地计算机上,浏览到(或找到WAMP安装的位置)c:\\ wamp \\ bin \\ php \\ php5.3.13 \\ ext

Rename php_curl.dll to php_curl.dll.old (or whatever you choose) and then copy the new file into the above directory. 将php_curl.dll重命名为php_curl.dll.old(或您选择的任何内容),然后将新文件复制到上面的目录中。

Restart WAMP Server 重启WAMP服务器

All should be working ok now. 一切都应该正常工作。

I had the same problem with php-5.5.26-Win32-VC11-x64 (on Windows) and I tried everything listed here with no luck. 我在php-5.5.26-Win32-VC11-x64(在Windows上)遇到了同样的问题,我尝试了这里列出的所有内容,但没有运气。 Finally I got it working by adding PHP installation directory to windows Path . 最后,我通过将PHP安装目录添加到Windows Path来实现它

With PHP 5.6.9 on Windows Server Core 2012 x64 cURL was not working, not showing up in phpinfo despite uncommenting php_curl.dll extension in my php.ini and restarting the Apache 2.4 service. 在Windows Server Core 2012 x64上使用PHP 5.6.9 cURL无法正常工作,尽管我的php.ini中没有注释php_curl.dll扩展并重新启动Apache 2.4服务,但没有显示在phpinfo中。 Added the php path and the php\\ext path to my $evn:path. 在我的$ evn:path中添加了php路径和php \\ ext路径。 No joy. 没有快乐。

Fix: I didn't need to download any other php_curl.dll file and couldn't find one for PHP 5.6 anyway. 修复:我不需要下载任何其他php_curl.dll文件,无论如何都找不到PHP 5.6。 What finally worked was to copy these three files into the Apache24\\bin folder then restart Apache: 最终工作的是将这三个文件复制到Apache24 \\ bin文件夹然后重启Apache:

libeay32.dll 的libeay32.dll

libssh2.dll libssh2.dll

ssleay32.dll Copying these to System or System32 was not needed. ssleay32.dll不需要将这些复制到System或System32。

If the problem persists after you uncomment the module from both php.ini files (that people are already talking about and which are located on apache folder and php folder) and even after you check that you got the php_curl.dll ** at 如果你从两个php.ini文件(人们已经在谈论并且位于apache文件夹和php文件夹中)取消注释模块后问题仍然存在,甚至在你检查到你得到php_curl.dll **之后

C:\\WAMP\\bin\\php\\php5.3.13\\ext C:\\ WAMP \\ BIN \\ PHP \\ php5.3.13 \\分机

YOU SHOULD TRY TO REPLACE THE ORIGINAL DLL THAT COMES WITH WAMPSERVER with one from this website: 您应该尝试使用本网站上的一个替换与WAMPSERVER一起使用的原始DLL

http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/ http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

My problem was there! 我的问题在那里! Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM