Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

curl

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. I downloaded the windows (binaries-only) distribution of PHP 5.2.10 from php.net and extracted that to my c:\PHP directory. 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. 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. I have found the PHP CURL installation page, this SO question which references this page, and this SO question. 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

In my Apache error log I get this each time the server starts:

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
  • Copied ssleay32.dll and libeay32.dll from C:\PHP to C:\WINNT\System32
  • Downloaded cURL for Win32 from curl.haxx.se and extracted the .zip file to C:\cURL
  • Added C:\cURL to my system PATH environment variable.
  • Verified that:
    • php.ini includes extension_dir="C:\PHP\ext"
    • The directory C:\PHP\ext contains php_curl.dll
    • The only php.ini file on my system is in C:\PHP (i.e. especially that there is no C:\WINNT\php.ini)
    • The Apache httpd.conf file includes the line PHPIniDir "C:/PHP/"

I have also rebooted the machine (several times, in fact...).

like image 818
Kip Avatar asked Aug 27 '09 20:08

Kip


People also ask

How do you check php cURL is enabled or not?

Create phpinfo. php file and save. phpinfo; ?> Then go to http://domainname/phpinfo.php to check whether CURL is enabled or not.

How does cURL PHP work?

cURL is a PHP extension that allows you to use the URL syntax to receive and submit data. cURL makes it simple to connect between various websites and domains. Obtaining a copy of a website's material. Submission of forms automatically, authentication and cookie use.


2 Answers

You don't have to reboot the computer, just restart the apache and the php module will read the new ini.
Did you change the correct 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?

Did you start the apache as a win32 service? 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).

edit:
"The specified procedure could not be found"
You need a dll that is compatible with your php version and build. Exactly what did you install and where did you get it from?

like image 66
VolkerK Avatar answered Sep 23 '22 00:09

VolkerK


Try this:

  1. Stop WAMP completely.
  2. Find your WAMP folder: C:\Path\To\WAMP\bin\Apache\ApacheVersion\bin\
  3. Edit that php.ini and uncomment extension=php_curl.dll
  4. Restart WAMP.

That should hopefully solve it.

*EDIT: Do the same thing @ C:\Path\To\WAMP\bin\php\PHPVersion\

like image 38
Mr. Smith Avatar answered Sep 21 '22 00:09

Mr. Smith