[php] How do I install cURL on Windows?

I have followed all the instructions here: 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.

I run the apache and run a PHP script. no problem. but when I run the php script with curl, it fails.

It returns: **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()

I output the php -i to see whether the right path to extension is called. It is correctly set:

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.

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.

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.

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. :(

This question is related to php windows curl windows-xp installation

The answer is


I'm using XAMPP, in which there are several php.ini files.

You can find the line in the php.ini files: ;extension=php_curl.dll

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


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 [email protected]:password http://localhost:3000/user/sign_in


I solved the problem.

In my apache, I have to specify:

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

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

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


I'm using XAMPP, in which there are several php.ini files.

You can find the line in the php.ini files: ;extension=php_curl.dll

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


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.

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:

    <?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);
    ?>

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


You may find XAMPP at http://www.apachefriends.org/en/xampp.html

http://www.apachefriends.org/en/xampp-windows.html explains XMAPP for Windows.

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.


Use the following steps to install curl:

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

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

  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!

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

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

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

Testing curl

  1. Open up the Windows Command Prompt terminal. (From the Start menu, click Run, then type 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"

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

  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.

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


I solved the problem.

In my apache, I have to specify:

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

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

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


I agree with Erroid, you must add PHP directory into PATH environment.

PATH=%PATH%;<Your_PHP_Path>

Example

PATH=%PATH%;C:\php

It worked for me. Thank you.


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 [email protected]:password http://localhost:3000/user/sign_in


You may find XAMPP at http://www.apachefriends.org/en/xampp.html

http://www.apachefriends.org/en/xampp-windows.html explains XMAPP for Windows.

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.


I'm using XAMPP, in which there are several php.ini files.

You can find the line in the php.ini files: ;extension=php_curl.dll

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


Use the following steps to install curl:

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

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

  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!

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

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

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

Testing curl

  1. Open up the Windows Command Prompt terminal. (From the Start menu, click Run, then type 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"

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

  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.

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


I agree with Erroid, you must add PHP directory into PATH environment.

PATH=%PATH%;<Your_PHP_Path>

Example

PATH=%PATH%;C:\php

It worked for me. Thank you.


I have tried everything - but nothing helped. After searching for several hours I found this information:

Apache 2.4.18 for some reason does not load php 7.2 curl. I updated my Apache to 2.4.29 and curl loaded instantly

http://forum.wampserver.com/read.php?2,149346,149348

What should I say: I updated Apache and curl was running like charm


You may find XAMPP at http://www.apachefriends.org/en/xampp.html

http://www.apachefriends.org/en/xampp-windows.html explains XMAPP for Windows.

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.


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.

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:

    <?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);
    ?>

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


I'm using XAMPP, in which there are several php.ini files.

You can find the line in the php.ini files: ;extension=php_curl.dll

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


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.

Finally I found this note at 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.

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.

Good luck!


I have tried everything - but nothing helped. After searching for several hours I found this information:

Apache 2.4.18 for some reason does not load php 7.2 curl. I updated my Apache to 2.4.29 and curl loaded instantly

http://forum.wampserver.com/read.php?2,149346,149348

What should I say: I updated Apache and curl was running like charm


You may find XAMPP at http://www.apachefriends.org/en/xampp.html

http://www.apachefriends.org/en/xampp-windows.html explains XMAPP for Windows.

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.


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.

Finally I found this note at 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.

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.

Good luck!


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.

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


I solved the problem.

In my apache, I have to specify:

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

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

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


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.

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


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to curl

What is the incentive for curl to release the library for free? curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number Converting a POSTMAN request to Curl git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to post raw body data with curl? Curl : connection refused How to use the curl command in PowerShell? Curl to return http status code along with the response How to install php-curl in Ubuntu 16.04 curl: (35) SSL connect error

Examples related to windows-xp

installing JDK8 on Windows XP - advapi32.dll error How to Create a script via batch file that will uninstall a program if it was installed on windows 7 64-bit or 32-bit How do I find files with a path length greater than 260 characters in Windows? Apache Maven install "'mvn' not recognized as an internal or external command" after setting OS environmental variables? How to access share folder in virtualbox. Host Win7, Guest Fedora 16? How to create ls in windows command prompt? How to fix an UnsatisfiedLinkError (Can't find dependent libraries) in a JNI project How to use random in BATCH script? How to delete or change directory of a cloned git repository on a local computer How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess

Examples related to installation

You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) Conda version pip install -r requirements.txt --target ./lib How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" PackagesNotFoundError: The following packages are not available from current channels: Tensorflow import error: No module named 'tensorflow' Downgrade npm to an older version Create Setup/MSI installer in Visual Studio 2017 how to install tensorflow on anaconda python 3.6 Application Installation Failed in Android Studio How to install pip for Python 3.6 on Ubuntu 16.10?