3

I have installed in my local computer apache 2.4 with PHP 7.1. I enabled curl in my php.ini (extension=php_curl.dll), but for some reason curl is not being loaded even after i enabled it, i made a phhinfo to check, and nothing, i also made a small script:

function isExtensionLoaded($extension_name){
    return extension_loaded($extension_name);
}

echo isExtensionLoaded('curl');

And nothing, is blank, what it means is not being loaded, is something missing? Im on Windows 10.

Vural
  • 8,666
  • 11
  • 40
  • 57
Pedro
  • 1,459
  • 6
  • 22
  • 40

5 Answers5

9

In my case it worked when I also copied nghttp2.dll to Apache bin directory

Nick Proto
  • 121
  • 1
  • 6
7

I was looking for a solution a really long time, until I decided to read some comments on the PHP documentation site: http://php.net/manual/de/curl.installation.php

I fixed coping the following list files from php folder (in my case C:\xampp\php7)

libeay32.dll
libssh2.dll
ssleay32.dll

Some people also had to move nghttp2.dll for it to work.

To your apache/bin folder (C:\xampp\apache\bin in my case).

I also copied those to C:\Windows\System32, but I do not think any of these files were loaded.

EDIT: I successfully deleted these dlls from system32 folder and was able to run curl afterwards

Deividas Šimas
  • 184
  • 1
  • 8
  • 1
    Those three and nghttp2.dll as well, for me. Cheers (also to @nick-proto) – Adam Cameron Oct 20 '17 at 11:23
  • I can't understand why third-party bundles are so popular yet you apparently always need to do workarounds like this for simple features. In the official PHP binaries curl always works out of the box :-? – Álvaro González Jun 08 '18 at 13:49
1

It works if you set ssl VERIFYPEER to false

curl_setopt($get, CURLOPT_SSL_VERIFYPEER, false);

it will works fine . you can also make curl work withe ssl by downloading the cacert.pem from https://curl.haxx.se/docs/caextract.html and Adding the cert to your php.ini file

curl.cainfo="C:\path\cacert.pem" 
openssl.cafile="C:\path\cacert.pem"

and

curl_setopt($get, CURLOPT_SSL_VERIFYPEER, true);

will work too this way you can prevent man-in-the-middle attacks, check this link for more details http://thisinterestsme.com/php-curl-ssl-certificate-error/

Gibolt
  • 42,564
  • 15
  • 187
  • 127
Snoopy Ohoo
  • 109
  • 1
  • 11
  • Thanks, bro! Your solution helped me with my overlapping problem here: ```https://stackoverflow.com/questions/71110013/how-to-enable-curl-locally-on-my-windows-10-so-that-my-php7-localhost-with-or-w?``` – Jerusalem Programmer Feb 14 '22 at 11:12
0

Make sure you have edited the right file. There should be separate file for CLI, Apache2 and other SAPIs. After doing so, restart the Apache2 server.

Ion Bazan
  • 723
  • 6
  • 16
0

It hard to guess why its not running and as I see you don't get error atm.

you should get errors but I am pretty sure you didn't set error-logging in your php.ini

First we need to activate logging to see why your extensions are not running correctly:

Please change/add following lines in your php.ini file:

display_startup_errors = On
error_log = 'c:/php-logs/php-error.log'

Now create the php-logs directory and php-log.log file

mkdir c:/php-logs
copy NUL c:/php-logs/php-error.log

Now restart the server. Now you should get the errors and please share the error-code so I can help

Update:

Enable mod_ssl in `httpd.conf``

LoadModule ssl_module c:\apache-2.2\modules\mod_ssl.so
Vural
  • 8,666
  • 11
  • 40
  • 57
  • Hello is giving me this error: "PHP Warning: PHP Startup: Unable to load dynamic library 'C:\PHP\ext\php_curl.dll" – Pedro Feb 27 '17 at 13:32
  • Its this: extension_dir = "C:\PHP\ext" – Pedro Feb 27 '17 at 14:21
  • Can you please check `httpd.conf` file, I guess mod_ssl.so is not installed and check my updated answer please – Vural Feb 27 '17 at 14:31
  • Yes, i already enabled, it was comment and i remove the comment :LoadModule ssl_module modules/mod_ssl.so – Pedro Feb 27 '17 at 15:00