29

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

Community
  • 1
  • 1
Kip
  • 107,154
  • 87
  • 232
  • 265
  • What does your phpinfo() output for extensions and environment variables/paths? – JYelton Aug 27 '09 at 20:20
  • Verify that (in addition to the above), PHP is actually loading the cURL extension. Do this by looking at the output of ``. There should be a block titled **curl**. If not, then it really isn’t being loaded for some reason. – Nate Aug 27 '09 at 20:27
  • @Nate: there is no curl section in phpinfo() – Kip Aug 27 '09 at 20:44
  • 5
    +1 for good documentation on what you tried, and for updating the final resolution – JYelton Aug 27 '09 at 21:55
  • I was getting similar errors like `PHP Warning: PHP Startup: Unable to load dynamic library 'D:\\php5\\ext\\php_curl.dll' - The operating system cannot run %1.\r\n in Unknown on line 0`, although I was not using wamp. I Took a fresh PHP 5.2.17 VC6 x86 Thread Safe zip from http://windows.php.net/download/ and it fixed the problem for me!! I was earlier having PHP 5.3.6 installation folder taken from teammates. I am working on a 64 bit system running windows 7 – Sandeepan Nath Jul 08 '11 at 08:43

7 Answers7

9

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
  • 95,432
  • 20
  • 163
  • 226
  • 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 Aug 27 '09 at 20:59
  • accepting this because you got me started down a different path that led to the solution. thanks for the help. – Kip Aug 27 '09 at 21:38
  • 3
    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 Aug 27 '09 at 21:41
  • +1 for 'change the *correct* php.ini'. Wamp 2.2 comes with a system tray that lets you enable extensions from a menu or navigate to the correct php.ini. – ErikE Feb 22 '13 at 13:50
7

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
  • 5,489
  • 11
  • 44
  • 60
  • 1
    With WAMP Server you can do it all through the status bar menu without having to open php.ini at all. – hookenz Aug 27 '09 at 21:45
  • 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 Aug 27 '09 at 21:51
  • @JYelton yes, you're correct, the A/M/P parts were installed separately, not from a package installation. – Kip Aug 27 '09 at 22:08
  • @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 Aug 27 '09 at 22:09
  • This is not working for x64 systems. However my Apache log says: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.13/ext/php_curl.dll' - The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. So my guess is that the php.ini edit just won't do the job. – Mike Aug 01 '12 at 17:31
1

This is what worked for me

Answered by Soren from another SO thread - CURL for WAMP

"There seems to be a bug somewhere. If you are experiencing this on Win 7 64 bit then try installing apache addon version 2.2.9 and php addon version 5.3.1 and switching to those in WAMP and then activating the CURL extension. That worked for me."

Community
  • 1
  • 1
Abhishek Rakshit
  • 691
  • 7
  • 12
1

This fixed it for me:

Go to here:

http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

Download 'php_curl-5.3.13-VC9-x64.zip'

Stop WAMP Server from Running

Extract the file 'php_curl.dll'.

On your local machine, browse to (or where your WAMP installation is found) c:\wamp\bin\php\php5.3.13\ext

Rename php_curl.dll to php_curl.dll.old (or whatever you choose) and then copy the new file into the above directory.

Restart WAMP Server

All should be working ok now.

RustyIngles
  • 2,433
  • 4
  • 27
  • 31
1

I had the same problem with php-5.5.26-Win32-VC11-x64 (on Windows) and I tried everything listed here with no luck. Finally I got it working by adding PHP installation directory to windows Path.

Master Drools
  • 728
  • 6
  • 18
1

With PHP 5.6.9 on Windows Server Core 2012 x64 cURL was not working, not showing up in phpinfo despite uncommenting php_curl.dll extension in my php.ini and restarting the Apache 2.4 service. Added the php path and the php\ext path to my $evn:path. No joy.

Fix: I didn’t need to download any other php_curl.dll file and couldn’t find one for PHP 5.6 anyway. What finally worked was to copy these three files into the Apache24\bin folder then restart Apache:

libeay32.dll

libssh2.dll

ssleay32.dll Copying these to System or System32 was not needed.

DCR
  • 14,737
  • 12
  • 52
  • 115
  • 1
    This also works for PHP7. And note that there already are libeay32.dll and ssleay32.dll in apache's bin. I had to replace them to make it work. – todinov Feb 02 '16 at 20:43
  • This just worked for me using Apache 2.4 and PHP 7.0.3, thanks! – MicBehrens Feb 07 '16 at 15:04
  • There is no need to copy the files, setting the path properly will work BUT if you already have libeay32.dll and ssleay32.dll in apache's bin you have to kill them. In my case I upgraded from 5.6 to 7 and already had Apache 2.4 running, which I did not want to change. After changing all dirs to point to php 7 curl did not work, and path was properly set, but the files above were found in apache dir, so curl dll never searched PHP dir for the correct ones. – Sergio Negri May 02 '17 at 14:47
0

If the problem persists after you uncomment the module from both php.ini files (that people are already talking about and which are located on apache folder and php folder) and even after you check that you got the php_curl.dll ** at

C:\WAMP\bin\php\php5.3.13\ext

YOU SHOULD TRY TO REPLACE THE ORIGINAL DLL THAT COMES WITH WAMPSERVER with one from this website:

http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

My problem was there! Hope it helps.

Lothre1
  • 3,523
  • 7
  • 43
  • 64