php 如何在 Windows 上安装 cURL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/181082/
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
How do I install cURL on Windows?
提问by murvinlai
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/
我已按照此处的所有说明进行操作:http: //www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/
to install & config apache get the PHP5 packages and get the CURL packages.
安装和配置 apache 获取 PHP5 包并获取 CURL 包。
I run the apache and run a PHP script. no problem. but when I run the php script with curl, it fails.
我运行 apache 并运行一个 PHP 脚本。没问题。但是当我用 curl 运行 php 脚本时,它失败了。
It returns: **Call to undefined function curl_version() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testing.php on line 5**
它返回: **Call to undefined function curl_version() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testing.php on line 5**
In which line 5 is a called to curl_init()
其中第 5 行被称为 curl_init()
I output the php -i to see whether the right path to extension is called. It is correctly set:
我输出 php -i 以查看是否调用了正确的扩展路径。它设置正确:
extension_dir => C:\PHP\ext => C:\PHP\ext
cURL support => enabled
cURL Information => libcurl/7.16.0 OpenSSL/0.9.8g zlib/1.2.3
I even tried to run curl_version()but still, same kind of error comes up.
It looks like the PHP can't find the CURL extension, but the php.ini(and also php -i) shows that it is set.
我什至试图运行,curl_version()但仍然出现同样的错误。
看起来 PHP 找不到 CURL 扩展名,但是php.ini(还有 php -i)表明它已设置。
any idea? :)
任何的想法?:)
P.S> System I m running on:
Windows XP
Apache 2.2
PHP 5.2.6
CURL Win32 Generic Binaries: Win32 2000/XP metalink 7.19.0 binary SSL enabled Daniel Stenberg 249 KB
I didn't get this:
我没有得到这个:
Win32 2000/XP 7.19.0 libcurl SSL enabled Günter Knauf 1.55 MB
Should I get this one instead?
The reason I need to use CURL is that it is the requirement from my project. So, I can only stick with that. XAMPP... how does it work in Windows? Is there any site that you can recommend? Thanks.
我需要使用 CURL 的原因是它是我的项目的要求。所以,我只能坚持下去。XAMPP...它在 Windows 中是如何工作的?有没有可以推荐的网站?谢谢。
I have tried a lot of things on installing cURL and check everything, but still, I'm stilling circling around the problem and have no idea what's going on.
我已经尝试了很多关于安装 cURL 并检查所有内容的方法,但是,我仍然在围绕这个问题盘旋,不知道发生了什么。
The Apache server uses the right PHP.ini. and the PHP.ini has the correct extension_dir and extension=php_curl.dll I have no idea why it doesn't work. even I follow every step for setting it up. :(
Apache 服务器使用正确的 PHP.ini。并且 PHP.ini 具有正确的 extension_dir 和 extension=php_curl.dll 我不知道为什么它不起作用。甚至我按照每一个步骤进行设置。:(
采纳答案by SchizoDuckie
You're probably mistaking what PHP.ini you need to edit. first, add a PHPinfo(); to a info.php, and run it from your browser.
您可能误解了需要编辑的 PHP.ini。首先,添加一个 PHPinfo(); 到 info.php,然后从浏览器运行它。
Write down the PHP ini directory path you see in the variables list now! You will probably notice that it's different from your PHP-CLI ini file.
立即记下您在变量列表中看到的 PHP ini 目录路径!您可能会注意到它与您的 PHP-CLI ini 文件不同。
Enable the extension
启用扩展
You're done :-)
你完成了 :-)
回答by curiousBoy
Use the following steps to install curl:
使用以下步骤安装 curl:
Open https://curl.haxx.se/dlwiz?type=binin a browser.
Select your operating system in the dropdown box: either Windows /Win32 or Win 64. Click Select!
For Win 32, choose whether you will use curl in a Windows Command Prompt (Generic) or in a Cygwin terminal (cygwin). For Win 64, choose whether you will use curl in a Windows Command Prompt (Generic) or MinGW (MinGW64). Click Select!
If required, choose your Windows operating system. Finish.
Click Download for the version which has SSL enabled or disabled
Open the downloaded zip file. Extract the files to an easy-to-find place, such as C:\Program Files.
在下拉框中选择您的操作系统:Windows /Win32 或 Win 64。单击选择!
对于 Win 32,选择是在 Windows 命令提示符(通用)还是在 Cygwin 终端 (cygwin) 中使用 curl。对于 Win 64,选择在 Windows 命令提示符(通用)或 MinGW (MinGW64) 中使用 curl。点击选择!
如果需要,请选择您的 Windows 操作系统。结束。
单击启用或禁用 SSL 的版本的下载
打开下载的 zip 文件。将文件解压缩到易于查找的位置,例如 C:\Program Files。
Testing curl
测试卷曲
Open up the Windows Command Prompt terminal. (From the Start menu, click Run, then type cmd.)
Set the path to include the directory where you put curl.exe. For example, if you put it in C:\Program Files\curl, then you would type the following command: set path=%path%;"c:\Program Files\curl"
打开 Windows 命令提示符终端。(从开始菜单中,单击运行,然后键入 cmd。)
设置路径以包含放置 curl.exe 的目录。例如,如果您将它放在 C:\Program Files\curl 中,那么您将键入以下命令:set path=%path%;"c:\Program Files\curl"
NOTE: You can also directly copy the curl.exe file any existing path in your path
注意:您也可以直接将 curl.exe 文件复制到您路径中的任何现有路径
- Type curl. You should see the following message: curl: try 'curl –help' or 'curl –message' for more information This means that curl is installed and the path is correct.
- 键入卷曲。您应该看到以下消息: curl: try 'curl –help' 或 'curl –message' 了解更多信息 这意味着 curl 已安装且路径正确。
回答by boxoft
I'm using XAMPP, in which there are several php.ini files.
我正在使用 XAMPP,其中有几个 php.ini 文件。
You can find the line in the php.ini files:
;extension=php_curl.dll
您可以在 php.ini 文件中找到该行:
;extension=php_curl.dll
Please remove ;at the beginning of this line. And you may need to restart apache server.
请删除;此行的开头。您可能需要重新启动 apache 服务器。
回答by Erroid
I had also problems with this. After all these steps made correctly and some fixed misunderstandings (there is no extensions_dir but extension_dir, and there is no sessions.save_path but session.save_path) nothing works.
我也遇到了这个问题。在所有这些步骤都正确完成和一些固定的误解之后(没有 extensions_dir 而是 extension_dir,没有 session.save_path 但没有 session.save_path)没有任何作用。
Finally I found this note at php.net:
最后我在 php.net 上找到了这个注释:
Note: Note to Win32 Users: In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll must be present in your PATH. You don't need libcurl.dll from the cURL site.
注意:Win32 用户注意:为了在 Windows 环境中启用此模块,您的 PATH 中必须存在 libeay32.dll 和 ssleay32.dll。您不需要来自 cURL 站点的 libcurl.dll。
So I copied ssleay32.dll, libeay32.dll & php_curl.dll From /PHP to Windows/system32 and replaced already existing files (I noticed there were older versions of ssleay32.dll and libeay32.dll). After that I found CURL section in php_info(); and finally everything works.
所以我将 ssleay32.dll、libeay32.dll 和 php_curl.dll 从 /PHP 复制到 Windows/system32 并替换了已经存在的文件(我注意到有旧版本的 ssleay32.dll 和 libeay32.dll)。之后我在 php_info(); 中找到了 CURL 部分;最后一切正常。
Good luck!
祝你好运!
回答by Nuadu
Another answer for other people who have had this problem
其他遇到此问题的人的另一个答案
when you un comment the extension line, change it to:
当您取消注释扩展行时,将其更改为:
extension=C:/php/ext/php_curl.dll
or the location of the extension folder, for me it did not work until i did this
或扩展文件夹的位置,对我来说,在我这样做之前它不起作用
回答by Rakesh
Note: Note to Win32 Users In order to enable this module (cURL) on a Windows environment, libeay32.dll and ssleay32.dll must be present in your PATH. You don't need libcurl.dll from the cURL site.
注意:Win32 用户注意事项 为了在 Windows 环境中启用此模块 (cURL),您的 PATH 中必须存在 libeay32.dll 和 ssleay32.dll。您不需要来自 cURL 站点的 libcurl.dll。
This note solved my problem. Thought of sharing. libeay32.dll & ssleay.dll you will find in your php installation folder.
这篇笔记解决了我的问题。想到了分享。libeay32.dll 和 ssleay.dll 您将在 php 安装文件夹中找到。
回答by TrentCoder
I recently installed Curl on PHP5 for Windows Vista. I did notenable the CURL library when I initially installed PHP5, so nothing about Curl was showing up in phpinfo() or php.ini.
我最近在 PHP5 上为 Windows Vista 安装了 Curl。我在最初安装 PHP5 时没有启用 CURL 库,所以在 phpinfo() 或 php.ini 中没有显示任何关于 Curl 的内容。
I installed CURL by re-running the PHP5 installer (php-5.2.8-win32-installer.msi for me) and choosing "Change". Then, I added the CURL component. Restart Apache, and CURL should work. CURL will show up in phpinfo(). Also, here is a sample script you can run to verify it works. It displays an RSS feed from Google:
我通过重新运行 PHP5 安装程序(对我来说是 php-5.2.8-win32-installer.msi)并选择“更改”来安装 CURL。然后,我添加了 CURL 组件。重新启动 Apache,CURL 应该可以工作了。CURL 将显示在 phpinfo() 中。此外,这里有一个示例脚本,您可以运行以验证它是否有效。它显示来自 Google 的 RSS 提要:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'http://news.google.com/news?hl=en&topic=t&output=rss');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec ($ch);
echo $contents;
curl_close ($ch);
?>
回答by boxoft
You may find XAMPP at http://www.apachefriends.org/en/xampp.html
您可以在http://www.apachefriends.org/en/xampp.html找到 XAMPP
http://www.apachefriends.org/en/xampp-windows.htmlexplains XMAPP for Windows.
http://www.apachefriends.org/en/xampp-windows.html解释了适用于 Windows 的 XMAPP。
Yes, there are 3 php.ini files after installation, one is for php4, one is for php5, and one is for apache. Please modify them accordingly.
是的,安装后有3个php.ini文件,一个是php4的,一个是php5的,一个是apache的。请相应地修改它们。
回答by RizonBarns
I agree with Erroid, you must add PHP directory into PATH environment.
我同意 Erroid,您必须将 PHP 目录添加到 PATH 环境中。
PATH=%PATH%;<Your_PHP_Path>
Example
例子
PATH=%PATH%;C:\php
It worked for me. Thank you.
它对我有用。谢谢你。

