BeetleJuice
BeetleJuice

Reputation: 40916

Why does PHP refuse to enable cURL on Windows

I am using PHP 5.5.25 with Apache 2.4 on Windows 7 x64 and I am unable to activate the cURL module. I have looked around and tried all I could think of. Please assist:

What else could explain why the cURL module is not enabled?

Upvotes: 8

Views: 9628

Answers (4)

Tobia
Tobia

Reputation: 9524

Every time I had an issue with php modules the it was related to libraries lack or overlap.

Let's say that the best option is to add php folder to PATH env variable.

However sometimes it is not enought. If php standalone (without apache) loads the module, probably the dll in php folder are ok but apache doesn't load them because some other folders with same libraries has priority (es. system32 or other programs).

In this case just copy all dll in main php folder into apache/bin folder.

Upvotes: 0

Rohan Khude
Rohan Khude

Reputation: 4893

on windows the cURL execution wants SSL certificate. may be because of that others error is showing.

Put the below code before curl_exec(curlHandle) to ignore checking for SSL certificate

//to ignore the SSL certificate in windows
        curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER,false);

Upvotes: 2

BeetleJuice
BeetleJuice

Reputation: 40916

Credit goes to @Steven Hilder for pointing me in the right direction.

The problem was that Windows could not see libssh2.dll, another DLL that was in PHP's directory. Copying this file to C:\Windows\SysWOW64 and C:\Windows\System32, along with the other two DLL files from my OP (libeay32.dll and ssleay32.dll) worked.

I am uncomfortable with this solution though because when the time comes to update to a new PHP version I will have a harder time remembering to overwrite these DLLs with the new version. Therefore, I decided to remove all 3 DLLs from the System32 and SysWOW64 directories. Instead, I just added the PHP bin directory to the Windows' PATH variable, so that the next time the OS is looking for a missing file, it will also look in that directory. This has the added bonus that if a similar problem with another DLL occurs, it will be resolved automatically.

To add the PHP bin to Windows' PATH:

  1. From the Start Menu search bar, search for and select Advanced system settings
  2. Click Environment Variables. Scroll down the list of System variables to select Path and click Edit... to open the current PATH setting
  3. Append ;C:\php or whatever directory has php.exe to the current setting (semi-colon is used to separate paths).

Upvotes: 4

Steven Hilder
Steven Hilder

Reputation: 222

I think you'll need libssh2.dll in your PATH too.

Upvotes: 11

Related Questions