tags:

views:

1705

answers:

2

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...).

+2  A: 

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?

VolkerK
The sample code outputs `php.ini: C:\PHP\php.ini`, which is the one I've been editing. I've updated the question with the error from Apache's error.log. There's nothing relevant in system event viewer.
Kip
accepting this because you got me started down a different path that led to the solution. thanks for the help.
Kip
Kip, can you please post the solution you eventually found? Someone else who looks at this question in the future might not understand what you did to fix it.
Mr. Smith
@Boekwurm: I did, it is right there at the top of my post.
Kip
+3  A: 

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\

Mr. Smith
With WAMP Server you can do it all through the status bar menu without having to open php.ini at all.
Matt H
When reading this question originally I wanted to suggest the system tray menu icon for adding the extension to PHP, however the term "WAMP" also has also meant a Windows-based install of Apache, MySQL, and PHP, and not necessarily the package available from http://www.wampserver.com -- thus I held off on the menubar extension suggestion.
JYelton
@JYelton yes, you're correct, the A/M/P parts were installed separately, not from a package installation.
Kip
@Boekwurm Thanks for the help, although I stated in the question that I had already tried that. But yes, after figuring out that the problem was corrupt DLLs or something, I undid everything except the change in php.ini and it still works (see my second update to the question).
Kip
Perfect, thanks, now I know too! :)
Mr. Smith