php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76649 cURL module requires libssh2.dll
Submitted: 2018-07-20 14:31 UTC Modified: 2018-08-29 15:13 UTC
From: laucomm at gmail dot com Assigned: cmb (profile)
Status: Closed Package: cURL related
PHP Version: 7.2.8 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: laucomm at gmail dot com
New email:
PHP Version: OS:

 

 [2018-07-20 14:31 UTC] laucomm at gmail dot com
Description:
------------
Using the current Apache Lounge release (httpd-2.4.34-win64-VC15.zip) and thread safe PHP version (php-7.2.8-Win32-VC15-x64.zip), the cURL extension does not get loaded.
I have not tested the behavior with other PHP 7.2 versions.

Test script:
---------------
php.ini:
extension=curl

Expected result:
----------------
All cURL functions should be defined and the module should be loaded if activated in the php.ini file.

Actual result:
--------------
Error message:
PHP Fatal error:  Uncaught Error: Call to undefined function curl_init() in FILE

The phpinfo() output does not display any cURL settings.

In comparison, the mbstring or gd extensions do work fine and are displayed in the phpinfo() output.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-20 14:37 UTC] spam2 at rhsoft dot net
this is the UPSTREAM bugtracker - you are simply wrong here talking about precompiled apache lounge binaries

[root@buildserver:~]$ php -v
PHP 7.2.8-thelounge-broadwell (cli) (built: Jul 18 2018 11:42:42) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

[root@buildserver:~]$ php -m
[PHP Modules]
apcu
calendar
Core
ctype
** curl **
date
dom
exif
fileinfo
filter
gd
geoip
hash
iconv
imagick
imap
intl
json
libxml
mailparse
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
Phar
Reflection
session
SimpleXML
soap
SPL
standard
tidy
xml
xmlwriter
zip
zlib
 [2018-07-20 17:10 UTC] laucomm at gmail dot com
I think it is highly unlikely that this issue is connected to the compilation source of Apache 2.4. It is PHP that is loading it's extensions, not Apache. I just mentioned the Apache version and source to describe the environment (Windows users usually do not compile there own binaries).

I believe that the officially compiled PHP 7.2.8 binaries for Windows (https://windows.php.net/downloads/releases/php-7.2.8-Win32-VC15-x64.zip) are containing a non-working (non-loading) version of cURL.
 [2018-07-20 17:16 UTC] laucomm at gmail dot com
As implicitly suggested, here the version and modules output:

PS C:\Program Files\php> .\php.exe -v
PHP 7.2.8 (cli) (built: Jul 18 2018 10:03:03) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
PS C:\Program Files\php> .\php.exe -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl  <--
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
Phar
readline
Reflection
session
SimpleXML
soap
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

PS C:\Program Files\php>

It can be seen, that curl is listed, bu it is not listed in the phpinfo() output and no cURL functions are available.
 [2018-07-21 12:59 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-07-21 12:59 UTC] cmb@php.net
Are you absolutely sure that both APIs use the same ini settings?
 [2018-07-22 17:35 UTC] laucomm at gmail dot com
If by "both APIs" you mean the php.exe being called directly with the "-m" parameter and php being loaded by apache as a module, than yes.

When I remove the "extension=curl" line from the php.ini file, the "php.exe -m" output is missing the "curl" line as expected.
 [2018-07-22 17:38 UTC] cmb@php.net
-Status: Feedback +Status: Open -Assigned To: cmb +Assigned To:
 [2018-07-22 17:57 UTC] spam2 at rhsoft dot net
that only proves that you modified the config for the cli successful so hell look at phpinfo() output which configs the webserver is using and enable display _startup_errors (I'm at a mobile so please look for exactly name) and make sure you have set a proper writable error_log

when your cli can load the extension it is for sure a local config issue and as said this is the wrong bug tracker
 [2018-07-22 18:13 UTC] requinix@php.net
-Summary: cURL module does not get loaded +Summary: cURL module requires libssh2.dll -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2018-07-22 18:13 UTC] requinix@php.net
As the top three comments on the cURL installation page say,
  http://php.net/manual/en/curl.installation.php
you need libssh2.dll in the path. The Apache download includes libcrypto and libssl but not libssh2.
Copying it from the PHP download to Apache's bin\ is sufficient.

Docs need updating.
 [2018-07-22 18:14 UTC] requinix@php.net
Oh. When in doubt with problems like this, make sure you have error logging enabled (including display_startup_errors) and that you've checked the appropriate error logs.
 [2018-07-22 19:34 UTC] laucomm at gmail dot com
I did read the following comments:
https://php.net/manual/en/curl.installation.php#122314

Though they appear to be out of date, I did try them out and copied the only one actually available of the three suggested files (libssh2.dll) to the Apache bin/ folder and also tried loading it with LoadFile (of course I restarted the service in between).

The function "curl_init()" is still undefined.

---

By the way, I guess because of the following fix to the PHP source, the INI settings of the loaded cURL module might not be displayed in the phpinfo() output of PHP 7.2.8:

https://github.com/php/php-src/commit/b585f043cb0078d01e982ff034d64421a97d8e8f#diff-ac978e3de205f1d14eb960e0eb15ef24

---

Also, I have cURL running fine on the same machine with a PHP 7.1.9.

Is there anybody with a windows machine, Apache 2.4 x64 and PHP 7.2.8 x64 that can confirm this issue?
 [2018-07-23 04:01 UTC] requinix@php.net
I was able to reproduce that cURL was not loaded, but copying libssh2.dll fixed it.

Did you do what I said about enabling logging? Did you check the Apache error log to see that PHP complained about "module not found" when trying to load the extension?

And phpinfo() will show a section for cURL, even if its INI settings aren't included.
 [2018-07-23 12:25 UTC] laucomm at gmail dot com
So here is the full deal:

cURL is not just an independent extension but depends on the 3 libraries libeay32, ssleay32 and libssh2 as described in the note and comments section of it's current doc:
https://secure.php.net/manual/en/curl.installation.php

Because the extension depends on external libraries being available to the web server, the distribution of those libraries with either the web server (Apache) or PHP is necessary. If the 3 libraries are alread being shipped with Apache, no steps are needed and cURL should just work fine. If any one of the libraries is missing, the cURL module will not work.

The official Apache site lists the folling links as the first two recommendended download locations for Apache binaries compiled for windows:
https://www.apachehaus.com/cgi-bin/download.plx
https://www.apachelounge.com/download/

The official binaries of PHP 7.2.8 for Windows are compiled against VC15.
The first location "ApacheHaus" does not provide VC15 compiled binaries, but "ApacheLounge" (the second location) does.
In the VC14 compiled distribution of both Apache binary providers, the 2 libraries libeay32 and ssleay32 are included, thus copying the missing libssh2.dll from the PHP distribution to the Apache bin/ folder will successfully load the cURL extension.

The VC15 compiled Apache distribution (only available from "ApacheLounge") does not include any of the needed 3 libraries. The older PHP distributions like PHP 7.1.9 did include all 3 needed libraries and made it possible to copy them to the Apache's bin/ folder. But the current PHP 7.2.8 distribution does just include 1 of the needed libraries (libssh2.dll).

So because neither Apache 2.4. x64 (VC15) nor PHP 7.2.8 x64 (VC15) are being shipped with the necessary libraries, they cannot be copied to Apache's bin/ folder.

This is not a simple documentation issue. PHP is not shipping all necessary libraries for cURL to work under current conditions anymore.
 [2018-07-23 13:28 UTC] ab@php.net
@laucomm thanks for the report. @requinix already has pointed to the right solution - either the DLLs need to be copied or at least be on teh path. That was your initial issue, as cli showed curl loaded on your side.

With regard to openssl - PHP 7.2 is shipped with OpenSSL 1.1.0 by default. If you need to use PHP as Apache module, then Apache needs to be linked with same OpenSSL version and same CRT. Apache Lounge are recommended Apache builds.

Perhaps it needs to be documented, whereby i'm not sure what exactly. With the DLL names - it's an implementation detail, the constellation can change in future. Perhaps one should document, if it isn't done already, that the PHP dir needs to be ensured to be on the path if used as Apache module.

Thanks.
 [2018-07-23 14:00 UTC] requinix@php.net
I just downloaded PHP from that earlier link you posted,
> https://windows.php.net/downloads/releases/php-7.2.8-Win32-VC15-x64.zip)
and it still has the three DLL files required for php_curl.dll to work: libcrypto-1_1-x64.dll, libssl-1_1-x64.dll, libssh2.dll. Just like it did yesterday when I downloaded it then.

I also just now went to the Apache Lounge to get their files. Again. Their VC15 also has libcrypto and libssl too but it does not have libssh2.

My answer about copying the libssh2 file was not some random guess: I reproduced your problem, identified the cause as the missing dependency, copied the file like I said, and it worked.
I don't know what files you're getting from where, but you're doing something wrong.
 [2018-07-23 14:04 UTC] laucomm at gmail dot com
@ab
The problem I see is, that only 1 of the 3 needed libraries for cURL is provided in the current PHP distribution. So if you don't download an old distribution of PHP or Apache to get the 2 missing libraries, you will not be able to get cURL to work with VC15.

So I suggest to include all 3 libraries again with upcomming Windows PHP distributions.
 [2018-07-23 14:17 UTC] laucomm at gmail dot com
@requinix@php.net
I do believe you, that you reproduced the issue on your end and found a working solution.
But I also believe, that the solution does not work on my end and that I did not misconfigure anything.

I will restore the VM I used to a vanilla state and reinstall Apache und PHP again with all the necessary steps, but I will take at least take 48h since I have to do some actual work first.
I'll see if I can record of video to document the process in case copying the libssh2.dll will again not resolve the issue.

Whatever the result, I will report back how it went.

Thanks for the patience!
 [2018-08-29 13:57 UTC] ab@php.net
-Status: Verified +Status: Not a bug
 [2018-08-29 13:57 UTC] ab@php.net
Thanks for the further info. Please don't mix modules, dependencies or CRT that are used in different PHP versions. Different branches can use different dependency constellations which is an internal detail. Thus, this is not a bug.

Thanks.
 [2018-08-29 14:12 UTC] requinix@php.net
-Status: Not a bug +Status: Verified
 [2018-08-29 14:12 UTC] requinix@php.net
> Thus, this is not a bug.
Right. However I switched this to a doc bug because the

> Note to Win32 Users
> In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll, or, as of OpenSSL 1.1
> libcrypto-*.dll and libssl-*.dll, must be present in your PATH. You don't need libcurl.dll from the cURL site.

note should be amended to also include libssh2.dll - as some of the user comments point out.
 [2018-08-29 15:12 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=345565
Log: Fix #76649: cURL module requires libssh2.dll

This also integrates the user notes 115953, 116019, 121543 and 122442.
 [2018-08-29 15:13 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-08-29 15:13 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:05 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=5e61ab9824ad1e80dc6ba43fc7669457d9eeeb77
Log: Fix #76649: cURL module requires libssh2.dll
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 14:01:30 2024 UTC