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

喜你入骨 提交于 2019-11-27 11:09:42

问题


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


回答1:


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?




回答2:


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\




回答3:


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




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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.



来源:https://stackoverflow.com/questions/1343514/how-to-get-curl-to-work-with-php-on-windows-wamp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!