如何在Windows上安装cURL ?

时间:2023-01-12 20:02:09

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**

未定义的函数返回:* *叫curl_version()C:\Program Files\Apache软件基金会\ Apache2.2 \根\测试。php在第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。我不知道为什么它不工作。甚至我也会按照每一步来设置它。:(

12 个解决方案

#1


20  

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。你需要编辑。首先,添加PHPinfo();一个信息。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 :-)

你完成了:-)

#2


46  

Use the following steps to install curl:

使用以下步骤安装curl:

  1. Open https://curl.haxx.se/dlwiz?type=bin in a browser.

    打开https://curl.haxx.se/dlwiz?类型=本在浏览器中。

  2. Select your operating system in the dropdown box: either Windows /Win32 or Win 64. Click Select!

    在下拉框中选择您的操作系统:Windows /Win32或win64。点击选择!

  3. 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!

    对于win32,请选择在Windows命令提示符(泛型)或Cygwin终端(Cygwin)中使用curl。对于win64,选择在Windows命令提示符(泛型)或MinGW (MinGW64)中使用curl。点击选择!

  4. If required, choose your Windows operating system. Finish.

    如果需要,请选择Windows操作系统。完成。

  5. Click Download for the version which has SSL enabled or disabled

    单击下载版本,该版本启用了SSL或禁用了SSL。

  6. Open the downloaded zip file. Extract the files to an easy-to-find place, such as C:\Program Files.

    打开下载的zip文件。将文件提取到一个容易找到的地方,例如C:\程序文件。

Testing curl

测试卷

  1. Open up the Windows Command Prompt terminal. (From the Start menu, click Run, then type cmd.)

    打开Windows命令提示符终端。(在开始菜单中,单击Run,然后键入cmd。)

  2. 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"

    设置路径以包含放置curl.exe的目录。例如,如果你把它放在C:\Program Files\卷发,然后将输入以下命令:设置路径= %路径%;“c:\ Program Files \旋度”

NOTE: You can also directly copy the curl.exe file any existing path in your path

注意:您也可以直接复制curl。exe文件您路径中的任何现有路径

  1. 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.
  2. 旋度类型。您应该看到以下消息:curl:尝试“curl -help”或“curl -message”获取更多信息,这意味着已经安装了curl,路径是正确的。

#3


13  

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文件:= php_curl.dll;扩展

Please remove ; at the beginning of this line. And you may need to restart apache server.

请删除;在这条线的开始。您可能需要重新启动apache服务器。

#4


9  

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.

我也有这个问题。在正确地完成所有这些步骤和一些固定的误解之后(除了extension_dir,没有extensions_dir,也没有会话)。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环境中启用这个模块,libeay32。dll和ssleay32。dll必须存在于您的路径中。你不需要libcurl。来自cURL站点的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。从/PHP到Windows/system32的dll,并替换已有的文件(我注意到ssleay32有更旧的版本。dll和libeay32.dll)。之后我在php_info()中找到了CURL部分;最后一切正常。

Good luck!

好运!

#5


2  

I recently installed Curl on PHP5 for Windows Vista. I did not enable the CURL library when I initially installed PHP5, so nothing about Curl was showing up in phpinfo() or php.ini.

我最近为Windows Vista在PHP5上安装了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.8 -win32-installer)来安装CURL。msi为我)和选择“改变”。然后,我加入了旋度分量。重新启动Apache, CURL就可以工作了。CURL将显示在phpinfo()中。此外,这里还有一个示例脚本,您可以运行它来验证它是否有效。它显示来自谷歌的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);
    ?>

#6


2  

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.

注意:要在Windows环境libeay32上启用这个模块(cURL),请注意Win32用户。dll和ssleay32。dll必须存在于您的路径中。你不需要libcurl。来自cURL站点的dll。

This note solved my problem. Thought of sharing. libeay32.dll & ssleay.dll you will find in your php installation folder.

这张便条解决了我的问题。思想的共享。libeay32。dll & ssleay。在php安装文件夹中可以找到dll。

#7


2  

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

扩展= C:/ php / ext / php_curl.dll

or the location of the extension folder, for me it did not work until i did this

或者扩展文件夹的位置,对我来说,直到我这样做它才起作用

#8


1  

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.html explains 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。请相应修改它们。

#9


1  

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.

它为我工作。谢谢你!

#10


0  

I solved the problem.

我解决了这个问题。

In my apache, I have to specify:

在我的apache中,我必须指定:

PHPIniDir "C://php" AddType application/x-httpd-php .php

PHPIniDir "C://php"添加类型应用程序/x-httpd-php .php

and for php.ini, instead of using the php.ini_recommend, use php.ini_dist to configure my php.ini.

和php。ini,而不是使用php。ini_recommend,使用php。ini_dist配置我的php.ini。

then make sure the php engine has turned on. then it works now. Thanks all.

然后确保php引擎已经打开。然后现在工作。谢谢所有。

#11


0  

You can use binary file of curl .download file from here : http://www.paehl.com/open_source/?CURL_7.22.0 Download the file and after extract put in to any drive and set the absolute path into environment now you can also use curl as a command in windows. like c:\curl -u user@example.com:password http://localhost:3000/user/sign_in

您可以从这里使用curl . Download文件的二进制文件:http://www.paehl.com/open_source/?比如c:\curl -u user@example.com:密码http://localhost:3000/user/sign_in

#12


0  

You can also use CygWin and install the cURL package. It works very well and flawlessly!!

您还可以使用CygWin并安装cURL包。它运行得非常好,完美无缺!!

#1


20  

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。你需要编辑。首先,添加PHPinfo();一个信息。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 :-)

你完成了:-)

#2


46  

Use the following steps to install curl:

使用以下步骤安装curl:

  1. Open https://curl.haxx.se/dlwiz?type=bin in a browser.

    打开https://curl.haxx.se/dlwiz?类型=本在浏览器中。

  2. Select your operating system in the dropdown box: either Windows /Win32 or Win 64. Click Select!

    在下拉框中选择您的操作系统:Windows /Win32或win64。点击选择!

  3. 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!

    对于win32,请选择在Windows命令提示符(泛型)或Cygwin终端(Cygwin)中使用curl。对于win64,选择在Windows命令提示符(泛型)或MinGW (MinGW64)中使用curl。点击选择!

  4. If required, choose your Windows operating system. Finish.

    如果需要,请选择Windows操作系统。完成。

  5. Click Download for the version which has SSL enabled or disabled

    单击下载版本,该版本启用了SSL或禁用了SSL。

  6. Open the downloaded zip file. Extract the files to an easy-to-find place, such as C:\Program Files.

    打开下载的zip文件。将文件提取到一个容易找到的地方,例如C:\程序文件。

Testing curl

测试卷

  1. Open up the Windows Command Prompt terminal. (From the Start menu, click Run, then type cmd.)

    打开Windows命令提示符终端。(在开始菜单中,单击Run,然后键入cmd。)

  2. 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"

    设置路径以包含放置curl.exe的目录。例如,如果你把它放在C:\Program Files\卷发,然后将输入以下命令:设置路径= %路径%;“c:\ Program Files \旋度”

NOTE: You can also directly copy the curl.exe file any existing path in your path

注意:您也可以直接复制curl。exe文件您路径中的任何现有路径

  1. 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.
  2. 旋度类型。您应该看到以下消息:curl:尝试“curl -help”或“curl -message”获取更多信息,这意味着已经安装了curl,路径是正确的。

#3


13  

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文件:= php_curl.dll;扩展

Please remove ; at the beginning of this line. And you may need to restart apache server.

请删除;在这条线的开始。您可能需要重新启动apache服务器。

#4


9  

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.

我也有这个问题。在正确地完成所有这些步骤和一些固定的误解之后(除了extension_dir,没有extensions_dir,也没有会话)。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环境中启用这个模块,libeay32。dll和ssleay32。dll必须存在于您的路径中。你不需要libcurl。来自cURL站点的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。从/PHP到Windows/system32的dll,并替换已有的文件(我注意到ssleay32有更旧的版本。dll和libeay32.dll)。之后我在php_info()中找到了CURL部分;最后一切正常。

Good luck!

好运!

#5


2  

I recently installed Curl on PHP5 for Windows Vista. I did not enable the CURL library when I initially installed PHP5, so nothing about Curl was showing up in phpinfo() or php.ini.

我最近为Windows Vista在PHP5上安装了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.8 -win32-installer)来安装CURL。msi为我)和选择“改变”。然后,我加入了旋度分量。重新启动Apache, CURL就可以工作了。CURL将显示在phpinfo()中。此外,这里还有一个示例脚本,您可以运行它来验证它是否有效。它显示来自谷歌的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);
    ?>

#6


2  

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.

注意:要在Windows环境libeay32上启用这个模块(cURL),请注意Win32用户。dll和ssleay32。dll必须存在于您的路径中。你不需要libcurl。来自cURL站点的dll。

This note solved my problem. Thought of sharing. libeay32.dll & ssleay.dll you will find in your php installation folder.

这张便条解决了我的问题。思想的共享。libeay32。dll & ssleay。在php安装文件夹中可以找到dll。

#7


2  

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

扩展= C:/ php / ext / php_curl.dll

or the location of the extension folder, for me it did not work until i did this

或者扩展文件夹的位置,对我来说,直到我这样做它才起作用

#8


1  

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.html explains 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。请相应修改它们。

#9


1  

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.

它为我工作。谢谢你!

#10


0  

I solved the problem.

我解决了这个问题。

In my apache, I have to specify:

在我的apache中,我必须指定:

PHPIniDir "C://php" AddType application/x-httpd-php .php

PHPIniDir "C://php"添加类型应用程序/x-httpd-php .php

and for php.ini, instead of using the php.ini_recommend, use php.ini_dist to configure my php.ini.

和php。ini,而不是使用php。ini_recommend,使用php。ini_dist配置我的php.ini。

then make sure the php engine has turned on. then it works now. Thanks all.

然后确保php引擎已经打开。然后现在工作。谢谢所有。

#11


0  

You can use binary file of curl .download file from here : http://www.paehl.com/open_source/?CURL_7.22.0 Download the file and after extract put in to any drive and set the absolute path into environment now you can also use curl as a command in windows. like c:\curl -u user@example.com:password http://localhost:3000/user/sign_in

您可以从这里使用curl . Download文件的二进制文件:http://www.paehl.com/open_source/?比如c:\curl -u user@example.com:密码http://localhost:3000/user/sign_in

#12


0  

You can also use CygWin and install the cURL package. It works very well and flawlessly!!

您还可以使用CygWin并安装cURL包。它运行得非常好,完美无缺!!