cURL with PHP and Apache on Windows
Code October 22nd, 2003Setting up cURL my linux server it was no problem at all, but I had a heck of a time getting cURL to work properly on my Windows test box with PHP and Apache. There are a lot of tricks scattered around on the web so here is my list of notes:
1. Only install PHP with the zip’d binaries. Don’t use the installer. I recommend deleting your current PHP installation and reinstalling with the binaries. Downloading the latest PHP has the added benefit of ensuring its compatible with the version of cURL you’ll download later. (I installed to D:\apps\php and will use that path for the rest of this example)
2. Edit your php.ini file:
- set extensions_dir to d:\apps\php\extensions
- set register_globals to On
- set sessions.save_path to d:\apps\php\temp (you need to create that directory first)
3. Copy php4ts.dll (located in d:\apps\php\) to your Apache bin folder
4. Copy libeay32.dll and ssleay32.dll (located in d:\apps\php\dlls\) to c:\windows\system32
5. Download cURL for Windows at: http://curl.haxx.se/download.html. I chose the Win32 - Generic by J?Hartroth. I recommend getting the SSL version in case you ever need SSL. I unzipped cURL to d:\apps\curl and will use that path for the rest of this example
6. [SSL INSTALL ONLY] Download OpenSSL for Windows from http://curl.haxx.se/download.html. (Its near the bottom of the page). Extract libssl32.dll to d:\apps\curl
7. [Windows XP Install Only] Check to see if you have the following file: c:\windows\system32\msvcr70.dll. If not, search for it in Google and download it to system32. You may get error messages without it.
8. Uncomment the curl line in your php.ini file to enable curl: extension=php_curl.dll
9. Finally edit your Apache httpd.conf file to enable php:
- Uncomment: LoadModule php4_module d:/apps/php/sapi/php4apache2.dll
- Add Line: AddType application/x-httpd-php .php
Test with the following PHP code:
$url = “http://www.thinkgeek.com”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$returned = curl_exec($ch);
curl_close ($ch);
echo $returned;
SSL NOTE: I kept getting no response when I tried using curl with SSL urls. I found that adding the following solved the problem:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
I have read that the proper solution is to use the ca-bundle.crt file for curl to be able to verify certificates but I haven’t tried this yet:
curl_setopt($ch, CURLOPT_CAINFO, ‘drive:\pathto\ca-bundle.crt’);








October 27th, 2004 at 2:33 am
Thanks for writting this. These steps worked like a charm on windows xp with php and apache installed.
Although it works, I don’t understand how apache or php knows of the executable in d:\apps\curl; this directory is not reference anywere in apace or php. Do they use them at all?
November 24th, 2004 at 8:28 pm
Thanks …. it worked great. Like the previous comment-er I also don’t know how apache or php knows of the whereabouts of the curl executable. Nevertheless it works and your instructions were very helpful.
December 7th, 2004 at 8:39 pm
Regarding the comments above, php does NOT need the standalone windows curl program to be installed. It implements libcurl in “php_curl.dll” which is included in the php extensions directory of the full windows binary installation. However, php does NOT include the certificate bundle file, which, AFAIK, is the only reason you’d need to download the standalone curl app for Windows — so you have a file to use when specifying “CURLOPT_CAINFO”.
February 20th, 2005 at 8:50 pm
Thanks for the tip about SSL - I was using code supplied by our CC solution (eway.com.au) & it didn’t include the ‘CURLOPT_SSL_VERIFYPEER’ line.
A few hours of hacking I’ll never get back … *sigh*
March 6th, 2005 at 10:21 pm
I’m not getting anywhere with this. I’ve got PHP and Apache working well (along with MySQL) on WinXP. I’m getting:
“Fatal error: Call to undefined function: curl_init() in C:\webpages\mark\test.php on line 20″
on the curl_init line of your sample code. I’ve followed your instructions, step by step as below.
1) Didn’t do anything - php already installed this way
done
2) made changes as specified
3) done
4) done
5) done
6) NA (don’t care about ssl support)
7) file exists
9) done previously when installed php
Apache restarted before page loaded where error obtained. PHP runs fine - phpMyAdmin and I are getting along famously. Other php pages loading. Just cURL doesn’t want to work.
Any suggestions for troubleshooting? I’m a bit of a newbie at this whole thing. Thanks for your help.
March 8th, 2005 at 7:04 am
Thanks very much, it worked great for me!
April 16th, 2005 at 6:16 am
thanks it works!
May 16th, 2005 at 9:25 am
omg, you clever, clever person!! i’ve been winding myself up about this at work for days
your solution totally worked!! *hugs*
June 10th, 2005 at 2:42 am
Hello,
I have got PHP With IIS in win-XP.I am getting one error in the below program as follows.
“Fatal error: Call to undefined function: curl_init()”
This is the program……….
$curlPost = ‘pop=’ . urlencode($pop) . ‘&alias=’ . urlencode($uid) . ‘&pass=’ . urlencode($txtPass) . ‘&SUBMIT=Send’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘put here url whihc needs to be executed’);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);
curl_close($ch);
So i don’t know how to install curl and configure this.please help me as soon as possible.
please give me the easy steps to go one by one.
Thanks very much.
June 22nd, 2005 at 5:11 am
Thanks for the instructions.
Yet I have a problem with posting to a test page I have on my localhost. When I use curl to post:
$post = Array();
$post[1] = urlencode(’test1′);
$post[2] = urlencode(’test2′);
$post[3] = urlencode(’test3′);
$curl = curl_init(”http://localhost/curltest/post.php”);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($curl);
curl_close($curl);
—- post.php
echo “CONTENTS:”;
print_r($_POST);
With my understanding of curl, this should print the POST arrays contents which it received via curl.
But I get nothing.
Can anyone help me? Thanks in advance
July 2nd, 2005 at 7:18 pm
thanks very much for the info, worked very well.
July 8th, 2005 at 4:37 pm
Hi,
I’ve a problem with curl…
How can I test if the port 443 are open or closed? (is it available or not?)
I run the following script to access my bank url, but get the errormessage :”couldn’t connect to host “..
Thanks
Enes
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://xxxxx.com”);
curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
}
July 30th, 2005 at 3:56 am
I can run my apache after adding this line in my httpd.conf :LoadModule php4_module c:\php\sapi\php4apache2.dll
c:\php is my php home dir.
Pls give comment.
August 2nd, 2005 at 1:23 am
Hi, thanks for these instructions. Only problem i am facing is, images don’t show up. It works fine but only images of the target site don’t show up. i am using windows 2003 server. do the directy session.save needs to have some special permissions? thanks
August 3rd, 2005 at 5:37 pm
Excellent…. Couldn’t find the lines in step 9 but figured as already had PHP and Apache working not needed.
Your guide - saved me a lot of time!!
Cheers
Oliver
September 4th, 2005 at 2:01 am
I was under the impression that values only needed to be url encoded if the ‘GET’ method was being used.
Could someone confirm whether it is necessary or not to urlencode values when CURLOPT_POST is being used. //Thank you - Abu Aaminah
September 13th, 2005 at 10:00 am
To those of you who experienced “Fatal error: Call to undefined function: curl_init()” error:
I got the same error message, and I restarted Apache. Then it worked 100%!
Nice article! =)
September 27th, 2005 at 5:31 pm
Thank You!!!!!!! It works great. Keep up the good work.
Awsome!!!! Thank you
-M@
September 28th, 2005 at 11:29 pm
What are the procedures for setting this cURL with ssl support using php 5 and iis6?
September 29th, 2005 at 2:10 am
Whats the setup procedure for iis6 and cURL with php5?
October 10th, 2005 at 7:34 am
Hello,
I am php web programmer looking for php curl support. I tried to find curl library for windows platform, but there several links on google that gives php_curl2.dll information. But the problem is that there is no link to download that files.
Please help me. send your suggetion on mukeshvariya34@yahoo.com
October 14th, 2005 at 1:04 am
I’m using php 4.3.11 on Windows2k3 to talk to SalesForce.com’s web services (using the PEAR SOAP libraries). I was getting error “SSL certificate problem, verify that the CA cert is OK” when I tried to talk to the https SalesForce server.
You can fix the problem directly using Tony’s CURLOPT_CAINFO info at the end of his first post, but if you don’t want to go hacking into the PEAR library files to find where curl_init is called, you can fix it when you initialized SOAP:
get the ca-bundle.crt out of the the cURL source distribution(http://curl.haxx.se/download.html). It lives in the lib folder
put it somewhere on your server, like c:\windows
right before you initialize SOAP_Client, use SOAP_Client->setOpt with CURLOPT_CAINFO to point to the ca-bundle.crt
class WebService_SforceService_Soap extends SOAP_Client
{
function WebService_SforceService_Soap() {
$this->setOpt(’curl’, CURLOPT_CAINFO, ‘c:\windows\ca-bundle.crt’);
$this->SOAP_Client(”https://www.salesforce.com/services/Soap/u/2.5″, 0);
}
…
You can easily hack that idea for other SOAP uses.
October 14th, 2005 at 3:26 pm
Great tip Sellgren!
October 16th, 2005 at 8:16 am
Thanks Tony! This is a great tip. It even works with Zend Studio 4 which is the php IDE and debugger. Add the folowing lines to C:\Program Files\Zend\StudioServer\etc\php.ini
extension_dir=”C:\Program Files\Zend\StudioServer\lib\php_ext”
sessions.save_path=”C:\Program Files\Zend\StudioServer\lib\temp”
extension=php_curl.dll
then create the directory C:\Program Files\Zend\StudioServer\lib\temp. Then you have OpenSSL and Curl support running so you can debug your encrypted soap calls. Neat!
October 25th, 2005 at 7:25 pm
I thank you too!
I couldn’t figure out how to get curl working on my xp laptop.
Thanks!!!
October 26th, 2005 at 3:03 pm
Hi,
I am the client side of a SOAP service. I got the certificate from the server and I need to access the service using this certificate/key. I am working on Windows XP. The following code is written in PHP but doesn’t work. The message is: “Unable to retrieve WSDL”.
Any help is greatly appreciated.
======================
require_once (”SOAP/Client.php”);
# $options[’curl’][’CURLOPT_SSLKEY’]=”c:\certificate.pem”;
## $options[’curl’][’CURLOPT_SSLCERT’]=”c:\exportedcertificate.pfx”;
$options[’curl’][’CURLOPT_SSLCERT’]=”c:\certnew.cer”;
$options[’curl’][’CURLOPT_SSLKEY’]=”c:\server.keystore”;
$options[’curl’][’CURLOPT_SSLKEY’]=”c:\certificate.pem”; ?????????should be this
$options[’curl’][’CURLOPT_SSLCERTPASSWD’]=”pw”;
$options[’curl’][’CURLOPT_SSL_VERIFYPEER’]=0;
$options[’curl’][’CURLOPT_SSL_VERIFYHOST’]=0;
$options[’curl’][’CURLOPT_VERBOSE’]=1;
$options[’curl’][’CURLOPT_CAINFO’]=??????? what should this be?
$soapclient = new SOAP_Client(’https://…./postal.asmx?WSDL’, true, false, $options);
print_r ($soapclient);
======================================
When print out the info of SOAP_Client object, I got “Unable to retrieve WSDL.
Thanks in advance
October 26th, 2005 at 6:12 pm
Hi, This is still Cynthia who posted the last messge. I also tried the following solution, the error message is
Error:
58 - unable to set certificate file (wrong password?)
But I am sure the password IS correct.. I gave the multiple settings to CAINFO and SSLCERT just for testing. I had a 5*4 combination for testing. nOne of them worked.
any help is appreciated!
================
#$url = “http://www.thinkgeek.com”;
$url=”https://…./postal.asmx?WSDL”;
$ch = curl_init($url);
#curl_setopt($ch, CURLOPT_CAINFO, ‘c:\curl-7.15.0\lib\ca-bundle.crt’);
#curl_setopt($ch, CURLOPT_CAINFO, ‘c:\certificate.pem’);
#curl_setopt($ch, CURLOPT_CAINFO,’c:\certnew.cer’);
#curl_setopt($ch, CURLOPT_CAINFO,’c:\exportedcertificate.pfx’);
#curl_setopt($ch, CURLOPT_CAINFO,’c:\server.keystore’);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSLCERT,’c:\certnew.cer’);
#curl_setopt($ch, CURLOPT_SSLCERT,’c:\certificate.pem’);
#curl_setopt($ch, CURLOPT_SSLCERT,’c:\exportedcertificate.pfx’);
#curl_setopt($ch, CURLOPT_SSLCERT,’c:\server.keystore’);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD,’xzhengpw’);
##curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$returned = curl_exec($ch);
echo $returned;
if ($returned == NULL) {
echo “Error:”;
echo curl_errno($ch) . ” - ” . curl_error($ch) . “”;
}
curl_close ($ch);
Thanks a lot
November 17th, 2005 at 10:42 pm
I have a working Apache2 PHP5 server running on Windows XP. After following Tony’s instructions I am experiencing the same trouble as several users above.
I have posted a php web page with Tony’s testing code. The browser answers with the following error code:
Fatal error: Call to undefined function curl_setopt() in C:\Data\GNK-site\Curl\CurlTest.php on line 9.
Having no prior experience with CURL, I’m not sure if the problem lies in configuration or in the posted test page.
According to PHP.NET, Curl must be compiled into PHP5, yet Tony has not included any compile procedures in the instructions.
I would appreciate any suggestions/explanations you might offer. I can be reached directly at geno11@softhome.net.
Gene K.
November 18th, 2005 at 2:35 am
Supplement to my previous post: I installed Apache2, PHP, MySQL, and CURL in the WinXP “Program Files” directory which contains a space. Even though everything else is working properly, could the space in the path be causing my problem?
December 4th, 2005 at 4:55 pm
Thanks man.
I was frustrated with getting nothing for SSL sites when it worked ok with HTTP sites and also with HTTPS from the command line.
You are my hero…
December 14th, 2005 at 4:54 am
Hie
I aslo installed php5 and Apache on winXP and these are working fine.I followed tony spencer’s steps to installing cURL and used the test code given,I get no response.i also tried the following suggestions give but still I get no response.
Where could the problem be?Please help.
January 9th, 2006 at 1:32 pm
I get the same
Call to undefined function curl_init() in . . . crack smoking POS Windows box.
error that some others have been getting.
php -m says curl is a compiled in module. WTF???? If it’s a compiled in module then why is the function undefined?
January 21st, 2006 at 8:33 pm
Alright all, i just tested and it works fine here. This is how to enable curl in iis. First, make sure 3 files is in the c:\php dir, php_curl.dll, php4ts.dll, php.exe. You can install the binary version of php in windows. ALso, download the zip file of php. So you have both the binary n the zip file. The binary version doesnt have the file php_curl.dll and you must copy it from the zip version. Make sure all 3 files are using the same version. After that, edit php.ini to uncomment extension=php_curl.dll and test it with this small script:
Save this script call it curl.php and placed in the inetpud/wwwroot. Use a browser to point to the script eg: http://localhost/curl.php and if it works, you should get this message: string(40) “libcurl/7.14.0 OpenSSL/0.9.8a zlib/1.2.3″
By the way, also install openssl from here: http://www.shininglightpro.com/products/Win32OpenSSL.html
That will get curl working. Peace.
January 29th, 2006 at 3:09 pm
I am new to php and just wanted to pass along something I learned.
Verify the path to php.ini. You can do this by running phpinfo().
I was changing the wrong php.ini file and was going crazy.
The key is to make sure you are changing the right php.ini file.
This tutorial help
Thanks
February 1st, 2006 at 7:52 am
Hello sir,
I used curl according to you. i have installed all things according to u. but even after i faced following error:
Fatal error: Call to undefined function: curl_init() in d:\apache group\apache\htdocs\clients\try\test.php on line 3
so please tell me what should I do.
Thanking you
February 3rd, 2006 at 7:46 am
i tried all this, but still i get curl_init() not defined
February 17th, 2006 at 11:02 am
I am new to php and just wanted to pass along something I learned.
Verify the path to php.ini. You can do this by running phpinfo().
I was changing the wrong php.ini file and was going crazy.
Same here. thanks for the tip, tutorial works great.
March 2nd, 2006 at 12:24 am
Hi,
I’m working with curl in my client right now. I’ve tried my script in another server and it’s working and when I transfered it to another server, problem occurs:
Error 58: unable to set certificate file (wrong password?)
I don’t understand why this error occured. I haven’t changed any certificate file. I just copied everything and that’s is.
Here is the info of the new server:
PHP 5.0.4
While in my server its PHP 4.3.11.
Do you think the php version matters?
If you have time kindly give me some answers..
Thanks and God bless…
March 10th, 2006 at 5:50 am
dude, you totally f***ing rock.
i can’t express how completely fed up i’d become with uploading, testing, tweaking and re-uploading cURL intensive apps to my web host when i have a perfectly fine dev environment on my laptop…
well now, thanks to you that ‘clean room’ now features fully functioning cURL. THANKS MUCH.
btw, i can verify that adding:
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch,CURLOPT_CAINFO,’drive:/path/curl-ca-bundle.crt’);
right after the call to curl_init works like a charm for ssl url’s.
March 16th, 2006 at 4:07 pm
March 26th, 2006 at 4:23 pm
I just want to say that this was EXTREMELY helpful! Thanks so much!
April 11th, 2006 at 1:13 am
Hi,
I am a freshers and I am working on php for last 2 months.I am doing a project where multi tasking concept is needed,but as in php there is no direct multithreading concept,so I want to do my job with curl or multiprocess concept.I am using unix platform.Please help me in this context with some codes and examples having multitasking or parallel processing.
Thanks and regards,
Subhojit
April 11th, 2006 at 12:22 pm
This was extremely helpful. I thought I need to hack at this for 2 days… it took me 5 mins.
Thanks
April 12th, 2006 at 2:53 am
Please help me
I’m Using Php 5 And For connecting To Https
Please Help Me for Configuration Php.Ini
My error Is
wsdl error: HTTP ERROR: cURL ERROR: 7: Connect failed; No error
url: https://www.pec24.com:443/pecpaymentgateway/eshopservice.asmx?wsdl‘
http_code: 0
header_size: 0
request_size: 0
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0
namelookup_time: 0.031
connect_time: 0
pretransfer_time: 0
size_upload: 0
size_download: 0
speed_download: 0
speed_upload: 0
download_content_length: 0
upload_content_length: 0
starttransfer_time: 0
redirect_time: 0
April 18th, 2006 at 7:15 am
hello all
i am sorry for posting my doubt here, but found no way to post it.
i am new to curl and incorporating it with java to get the desire webpage. i had got curl lib but not able to work it with java, so pleease anybod who had worked over it then guide me.
Thanks in advance.
April 24th, 2006 at 12:31 am
That’s a great writing. I really find it very helpful while installing curl. It works quite nice.
Thanks for providing such a great document.
May 9th, 2006 at 10:49 pm
I don’t get it.. You downloaded curl and openssl into d:\apps\curl, but you don’t reference that path anywhere else in the configuration of httpd.conf or php.ini. When you enable curl in php.ini, you use the default curl library that comes with the php distribution, “extension=php_curl.dll”. So, how does php/apache know about the dlls you downloaded to d:\apps\curl? Doesn’t the above steps you outline just use the default php_curl.dll and not the other ones?? I tried the above steps, and I can’t use curl to query any https addresses…
May 11th, 2006 at 2:06 pm
I tried to do as told, but couldn’t fix the error. For those still with problems (as i was until a few minutes), please refer to
http://www.zend.com/pecl/tutorials/curl.php
May 29th, 2006 at 6:10 am
hi all
iam a JAVA programmer and iam new to curl. Can anyone can help me out to work in curl and incorporating its command in java api so as to run it from the console.
May 30th, 2006 at 5:15 am
For those with “Fatal error: Call to undefined function: curl_init()” that wasn’t fixed by any of the above comments.
I hard-coded the extensions directory (for me it is extension_dir = “C:/php-4.4.2-Win32/extensions/”) and all was schweet
June 5th, 2006 at 8:21 am
Hi
I am Hitesh Patel
I have yahoo addressbook grabber but i face problem to execute script call to undefined function curl_init()
plz send me reply how to execute my script.
inform me all the neccessary file that i have to set.
June 13th, 2006 at 1:52 pm
Worked like a charm! Thanks.
And yes, running SSL with ca-bundle.crt works too.
June 21st, 2006 at 6:34 am
can you please tell me
how can i encode the link with
urlencode and php
thanks
June 28th, 2006 at 12:15 pm
Really Worked Great…. Thank you very much. I should really appreciate your contribution.
June 28th, 2006 at 1:57 pm
This is not a comment, but a question,
I have two live applications running, which I cannot tell of here. Application A is a shopping site, and Application B is a Merchant Control Site:
Application A is hosted on a windows server. whilst Application B on a linux.
A posts form to B using simple HTML form for credit card approval, B replies back using form post at a specified URL at A, but always get an error on curl Could not Connect, any Ideas, any help very much appreciated am stuck on this for quite lots of days.
I have site C also that is on linux, and is also shopping site, C does the same process but does not get any error in receiving response back from A.
Any help is very much appreciated.
Please email me at s4shani83@hotmail.com
July 4th, 2006 at 2:36 am
Thanks for the article.
Very helpful.
July 24th, 2006 at 4:18 pm
All this time and it still works - Thanks
July 27th, 2006 at 8:54 am
xampp userse:
for those pulling as much hair out as me, read this list to ensure you have all php.ini copies covered:
http://www.menyhart.net/blog/developer-stuff/enabling-curl-on-xampp/
why there’s not one I don’t know…
August 2nd, 2006 at 8:59 am
Xampp inst. does not require any additional settings, but those mentioned by Tim above.
Thanks Tim
August 2nd, 2006 at 12:49 pm
If you’ve just installed PHP5 on windows XP, the extension dir may be “extension_dir={your_php_dir}/ext”, and not “extensions”.
Thanks Tony!
August 4th, 2006 at 4:12 am
Hi
I am prasenjit modak I have yahoo addressbook grabber but i face problem to execute script call to undefined function curl_init()
plz send me reply how to execute my script.
inform me all the neccessary file that i have to set.
August 4th, 2006 at 4:16 am
dear sir, i am not properly integrate curl in my php project .kindly tell me the procedure how to integrate these.when run the link then curl_init() is not found.
August 4th, 2006 at 5:26 am
You guys are the 80582 best, thanks so much for the help.
August 18th, 2006 at 6:18 pm
I realise this article is quite old – but I came across it so others might too.
First of all as jb correctly pointed out, you don’t need to install curl if you just want to use curl in php. Nor do you need to install openSSL to access secure pages using curl with PHP.
By the way, and this is important, setting CURLOPT_SSL_VERIFYPEER to false (or 0) undermines the security system – SO DON’T DO IT – It is not a solution to your problems.
To use ssl correctly, just download curl for the “curl-ca-bundle.crt” file as suggested by jb and give its location with CURLOPT_CAINFO.
Here’s a tip: don’t copy libeay32.dll and ssleay32.dll to your system32 dir. Instead add the php directory to your system PATH. This is recommended in other places in the php manual, but was left out on the curl page. To quote http://www.php.net/manual/en/install.windows.manual.php
“And as you’ll soon learn, the preferred method for installing PHP is to keep all PHP related files in one directory and have this directory available to your systems PATH.”
September 1st, 2006 at 2:27 am
Keep up the great work on your blog. Best wishes WaltDe
September 5th, 2006 at 9:32 pm
Hello there.
If you want to install cURL on Windows, make sure that you’ve copied “php.ini” from the PHP folder (mine is currently “php-4.3.5-Win32″) to your SYSTEM or SYSTEM32 folder (I’m still on Win ME, so it’s SYSTEM). Open the copied version to the SYSTEM folder and look out for these lines:
; Directory in which the loadable extensions (modules) reside.
extension_dir = “C:\php-4.3.5-Win32\extensions”
As you could see, just replace the VALUE of extension_dir to the full path (Windows-based PATH using BACK-slashes) of the folder “extensions” on your PHP folder.
Then copy all of these libraries (DLL’s) from the PHP folder into the SYSTEM folder:
php4ts.dll,
ssleay32.dll,
php_curl.dll, (inside “extensions”)
msvcrt.dll
I thought the last one should already be in the SYSTEM folder there
cURL can then be enabled by uncommenting the line ‘extension=php_curl.dll‘ in the php.ini file. Alternatively you can load the module dynamically in your script using:
<?php
dl(”php_curl.dll”);
?>
Create a simple PHP file that looks something like this:
<?php
echo phpInfo();
?>
… and save it as “phpInfo.php” or anything up to you. Then run it via your Web browser. If the cURL installation was done successfully and is now enabled, you’ll see the “curl” section from the page — mine is after “ctype and before “ftp“.
[Good Reference: http://www.Zend.com/pecl/tutorials/curl.php [NEW Window]”>http://www.Zend.com/pecl/tutorials/curl.php]
September 6th, 2006 at 10:08 am
Woopss!
Sorry… I was in a bit hurry when I posted my first comment
I’m pretty sure you can figure things I’ve ‘coded’ mistakenly like the <A>! Also the <br>s Heheheh…
September 12th, 2006 at 1:51 am
So i don’t know how to install curl and configure this.please help me as soon as possible.
please give me the easy steps to go one by one.
Thanks very much.
September 14th, 2006 at 9:52 pm
Why turn register_globals on? This is a security risk and is not recommended. I got curl working fine with this setting off.
September 27th, 2006 at 10:51 pm
Sorry, I just don’t get it. I need to post information from a secure site to a secure site which will write the information into a database and return a reply. How do I get curl to do this. The example above worked but how do I post.
This worked but how do I post to something like this?
$url = “http://www.thinkgeek.com”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$returned = curl_exec($ch);
curl_close ($ch);
echo $returned;
Thanks, I am getting closer.
October 26th, 2006 at 8:13 pm
I fixed my
Fatal error: Call to undefined function: curl_init()
issue on WinXP.
I followed the instructions above but refused to
believe that you need to put the php.ini file in
the windows/system32 directory. After all, if you
put php before the windows & system32 entries in your path windows should load these first. Right?
I don’t know and right now don’t care. I
put the php.ini file (after all modifications as
outline et al above) into the windows/system32 directory. I then got curl showing up in a phpinfo.php.
whew!
October 28th, 2006 at 8:13 pm
I check everything about your chack-list and still have
PHP Startup : unable to load dynamic library ‘C:\php\ext\php_curl.dll’
i am with PHP 5.0.2 under Windows XP SP2
if you or anybody have an idea.
November 14th, 2006 at 9:37 pm
Amazing!!! 10+
No pain! Easy install!
Thank you!!!
+++++++++++++++++++++++
November 15th, 2006 at 11:33 am
yes it does not work for me either, there is no php_cull.dll in tany directiory of that distribution as far as I can see
November 22nd, 2006 at 1:49 am
Just copied the php_curl file to php directory and uncommented extension=php_curl.dll and set globals on it worked on windows2000.
Thanks
Sundaresan
December 6th, 2006 at 6:07 pm
Thanks everyone, esp. Eric\Pokerface…
My “Fatal error: Call to undefined function: curl_init()” error was resolved after I realized I was changing the wrong php.ini file. Who knows why there’s a separate on in my apache\bin directory. Maybe I put it there a long time ago or maybe XAMPP makes a copy there.
C:\Program Files\xampp\apache\bin\php.ini
Searching my xampp directory tree showed more than one php.ini file.
C:\Program Files\xampp>grep -idl php php.ini*
File apache\bin\php.ini
File php\php.ini
File php\php.ini-dist
File php\php.ini-recommended
File php\php4\php.ini
File php\php4\php.ini-dist
File php\php4\php.ini-recommended
I’m running PHP Version 5.0.4
Thanks everyone!
January 3rd, 2007 at 3:36 am
Thank you sally
Now my curl is working like a knife on a butter.
Thanx again bye.
January 4th, 2007 at 4:10 am
hi,
that was really a great piece of work. excellent explanation. curl is now working fine.
thanks much
January 10th, 2007 at 1:42 am
I want to upload a file using cURL.
I have installed zlib and libgcc packages.
But i m not getting an parse error.
So any one having code for it with explanation
Please reply
April 17th, 2007 at 6:42 pm
this worked for me — it is from the php manual (http://www.php.net/curl)
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.
June 18th, 2007 at 1:13 am
How did you manage to set it up on Linux without compiling php? Please provide the steps.
June 21st, 2007 at 5:43 pm
Great Page.
But I was sitting behind a firewall and I had not set up the proxy. Thus whenever I executed the php script, I got a blank page!! Solution:
curl_setopt ($ch,CURLOPT_PROXY, “proxy_server:port”);
Also very good debug option: A must for beginners
print_r(curl_getinfo($ch));
echo “\n\ncURL error number:” .curl_errno($ch);
echo “\n\ncURL error:” . curl_error($ch);
July 14th, 2007 at 1:09 pm
Thanks works perfect!
July 15th, 2007 at 11:23 pm
hi,
currently i’m trying curl with tomcat5.5 and php5, i followed your steps, but I dont know how to do the step 9.
please guide me.
thanks in advance.
vanchin
August 31st, 2007 at 1:17 pm
For those that don’t work try this to see if you have the curl enable:
I had the php.ini file in the windows directory and was editing the php.ini on the php directory, and with that i found the problem.
September 5th, 2007 at 5:43 am
i am using php5 with apache server on windowsXP my curl library is also enable but i am getting this error:
7 Failed to connect to xx.xxx.xxx.xx (ip): Permission denied
plz help me
September 12th, 2007 at 4:11 pm
Not sure if this will help anyone because it appears that everyone who has installed PHP, IIS, and cURL didn’t encounter any issues.
My issue was that everything worked, PHP, IIS, cURL, but not cURL under SSL even after adding “curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);” to my test script. The answer, found on the PHP.net site (”http://fr.php.net/curl”), use …
“curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);”
It works…
September 23rd, 2007 at 9:14 am
Easily worked for me…thanks !
October 9th, 2007 at 3:50 am
hy … i installeted on that tutorial a xampp pack …and ” all`s greate ” but curl don`t running … isn`t in phpinfo is not a curl enable .. maby xamp pack don`t compil a php with curl ?
pls help me
November 14th, 2007 at 9:31 pm
Hello,
I have got PHP With IIS in win-XP.I am getting one error in the below program as follows.
“Fatal error: Call to undefined function: curl_init()”
So i don’t know how to install curl and configure this.please help me as soon as possible.
please give me the easy steps to go one by one.
Thanks very much.
January 13th, 2008 at 2:11 pm
Thanks a lot, your instructions really helped me out of this one
A little note to all XAMPP users,
php.ini is not loaded from the file found in the php installation directory, but from apache/bin/php.ini
January 22nd, 2008 at 6:56 pm
For those interested in just getting cURL capability going (perhaps because you already have PHP & Apache running but now need the curl stuff), just follow items 4&8 from the tutorial. the php_curl.dll won’t load (step
until you perform step #4 when you restart the Apache server.
March 31st, 2008 at 2:05 am
oh mate , that was awsome ,… how come u’r the only resource for this?
May 2nd, 2008 at 9:55 am
Can anyone help me get this working. I can’t get the curl module to load. I uncommented the line in the php.ini file and have the dlls in the system32 dir but, in phpinfo() the module does not show up.
May 5th, 2008 at 5:46 pm
Having same problem as g! above. Both copies of php.ini have been adjusted (one under c:\Program Files\PHP and one under c:\WINDOWS\system32), the Apache .conf file has been modified, the extension path has been set, etc., etc. but curl still refuses to load. Been working on this for 3+ days (pushing 30 hours). Oh yeah: Windows XP SPII, Apache 2.2, PHP 5.2.5, curl 7.18.1. Any obscure idea would help in this battle.
May 19th, 2008 at 1:00 pm
For some reason, Apache was not picking up the path for my php.ini file, but was looking in the C:WINDOWS/ folder for it. Another issue was that php was looking in c:php5/ext by default for my extensions. I placed the .ini folder in the C:WINDOWS/ folder and placed the ext folder in the default location and cURL loaded perfectly. This is only a short term solution, but at least it got me up and running. Hope this helps.
June 4th, 2008 at 4:08 am
June 5th, 2008 at 8:30 am
Thanks! I just did step #4 and uncommented the extensions for php_curl.dll and php_openssl.dll in the php.ini file; worked like a charm.
June 6th, 2008 at 11:39 pm
Like many of you, I had trouble installing CURL on a Windows Box running Apache and PHP. My exact setup is Windows XP with Apache 2.2.6, and PHP 5.2.6. (The latest releases of both.)
It seems to me that the new version of PHP does things a bit differently with respect to importing modules, and the instructions given here can’t really be applied to the current version of PHP without some modification. Obviously, I have no idea what these mods are, and you probably don’t either.
But, THERE IS A SOLUTION. When you install PHP via the .exe file, the default options are to install the program of PHP itself along with a few really common extensions. BUT, you can also install less commonly used extensions (like CURL) by simply checking them off under the little extensions box. I just did this and voila! - everything works.
No sense in killing yourself over this when the installer does it for you.
Good luck.
-Joe
June 9th, 2008 at 5:14 am
I have problem with the 9th step
- Uncomment: LoadModule php4_module (no line contains this string, so what have I to do. By the way I have added the following line(Tell me is it correct or not?)
LoadModule php4_module modules/mod_dir.so
d:/apps/php/sapi/php4apache2.dll(What is this?)
June 20th, 2008 at 1:39 am
You rock
Thanks so much.
July 16th, 2008 at 10:51 am
Curl Installation problem
I have Apache/2.2.4 (Win32)and PHP/5.2.1 installed on my PC, but I can’t get
the CURL extension to work. It does not show up when I display phpinfo and
when I run a program with CURL in it, I get an error message that the program
does not recognize the CURL function.
I had uncommented out extension=php_curl.dll in the php.ini file. In terms, of
the two files associated with CURL, libeay32.dll and ssleay32.dll, they are
both in my PHP root directory and my PHP/ext directory, as is php_curl.dll. I
have also put these the libeay32.dll and ssleay32.dll in my Windows/system and
Windows/system32 directories because someone had suggested it when I was
researching CURL installation problems. I had checked the PATH function to see
that all necessary directories are mentioned.
I have restarted Apache and the CURL function is still missing in phpinfo.
August 1st, 2008 at 5:33 pm
Thanks for this guide, I managed to get it working in no time at all. Just a couple of quick notes, when using php5 the test script needs to be changed to $url = ‘http://www.thinkgeek.com’; (single quotes) or it throws up an error. Also with my installation, I use the server package from devside.net, the line which needed to be uncommented in step 9 did not exist. However for anyone else who also doesnt see this line it didnt make any difference to the success of the installation.
August 6th, 2008 at 9:20 am
Another note. I added the PHP directory to the path in a Win XP machine, but it still wouldn’t work until I restarted the computer. Also, Apache 2.2.9 has its own ssleay and libeay files in the bin directory. Not sure if it helped, but I replaced them with the files from the php installation.
August 13th, 2008 at 1:51 am
It helps a lot. Thank you so much!