4
votes

I am having trouble getting cURL working on one of my servers. I have others set up exactly like this and they are working. Here is the error message in the system log:

PHP Fatal error: Call to undefined function curl_init()

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_curl.dll' - The specified module could not be found. in Unknown on line 0

I've been researching this all day and nothing has worked. Here's the current state of the server:

  • php.ini is in C:\php\
  • php_curl.dll is in C:\php\ext\
  • libeay32.dll and ssleay32.dll are in C:\php\
  • extension=php_curl.dll is uncommented in php.ini
  • Environment variable PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C\php;C:\php\ext;C:\Apache24\bin
  • phpinfo() shows that C:\php\php.ini is the config file being used
  • php.ini extension_dir = "C:\php\ext"
  • Apache is from here
  • PHP is from here
  • OS is Windows Server 2008 R2 Datacenter

I've restarted several times. Other extensions are loading from the extension directory. I've also tried re-downloading the PHP zip file and replacing C:\php with the contents of the freshly downloaded zip file. I had this problem on a different server a while back when I was updating PHP and Apache. Replacing C:\php with a new copy of the zip file did fix it, but it is not helping now.

I will be happy to provide any additional information you may need.

Thanks.


phpinfo() configure command

cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo".

7
does phpinfo() show that curl is enabled? Look for cURL support enabled you might need to recompile php with curl support... assuming you compiled yourself, maybe post your config.nice / config cmd - Joe T
phpinfo() only mentions curl under the module authors section. I did not compile PHP myself. I downloaded the zip of VC11 x86 Thread Safe from windows.php.net/download - it has always worked in the past. phpinfo() has a configure command at the top. I'm not sure if that will be of help, but I posted it above. - Mr. Squidward
well something must be different, i'd double check the package you're getting; if you have one of your past servers compare the phpinfo() - Joe T
I tried to copy C:\php from the old server to the new one and it still didn't work. Both top sections (system, build date, compiler, architecture, configure command, etc.) of phpinfo() are identical between the two servers. The old one does show that curl is enabled. - Mr. Squidward
@Mr.Squidward, so what was the solution of your problem? - Boris Garkoun

7 Answers

2
votes

In PHP 7.3:

  1. extension=php_curl
  2. copy libssh2.dll from C:\php into C:\apache\bin
  3. copy libcrypto-*.dll and libssl-*.dll from C:\php into C:\apache\bin (if it doesn't exist)
1
votes

Oops, "C\php" in PATH was missing a colon. Changed it to "C:\php" and it works now. I had a feeling it would turn out to be something like this... Oh well.

1
votes

We have faced similar problem in our Environment.

We uninstalled Apache and installed it again with following commands:

c:\Apache\bin httpd -k uninstall 
c:\Apache\bin httpd -k install 

and magic.... The problem is solved...

1
votes

In PHP 7.4:

It's a problem related to Windows, if you are using Apache2.x + Php, the trick consists in using LoadFile to force the loading of CURL as explained in my Guide. You don't need strange things or rituals to have CURL working on your machine, you only need edit httpd.conf and add this:

# load CURL library on Windows
LoadFile "${SRVROOT}/php/libssh2.dll"

Hope this helps.

0
votes

Unable to load dynamic library 'C:\php\ext\php_curl.dll'

correct answer should workable as environment path for c:\php is missed . so just add

In Control Panel -> Search -> Advanced System Settings and use the button Environment Variables.

Under System Variables find Path add the c:\php folder (or whatever path) and restart Apache.

0
votes

In my case, the problem was that I was taking another curl.exe file that was in the PATH before the one in C:\Windows\System32

-5
votes

also you need to change the curl.dll version, you must overwrite the version that comes with wamp server. C:/wamp/bin/php/ext.

You can download the right version from this link

http://www.mediafire.com/download/3ay381k3cq59cm2/php_curl-5.4.3-VC9-x64.zip

I hope it works for you!

font: http://forum.wampserver.com/read.php?2,85716,85932