无法找到包装器“ https”-您是否忘记在配置 PHP 时启用它?

问题在于问题本身。我已经做了一个彻底的调查,以解决这方面的问题,我知道有这方面的主题,我已经按照他们了,没有一个工作。话虽如此,我还是要列出目前为止我所做的一切。在我的 Windows XP 电脑上,我正在使用 Zend Debugging 版本的最新 Eclipse 运行 PHP 5.2.14。我有1GB 的内存。我在安装了 Apache、 MySQL 和 FileZilla 的情况下运行了 XAMPP。

在 XAMPP 上,我做了以下工作(Apache 在这些更改期间关闭) : 从 XAMPP 控制面板上点击 管理员,转到 https:// localhost/xampp/。从那以后,我接受了欢迎页面上这一行的证书:

对于 OpenSSL 支持,请使用 https://127.0.0.1或 https://localhost 的测试证书。

在同一个部分,我检查 phpinfo()。在「环境」一栏中,SERVER["HTTPS"]on。在“ Apache 环境”下,HTTPSOn。在“ PHP 变量”下,_SERVER["HTTPS"]On。在‘ Phar’下,OpenSSL supportdisabled(install ext/openssl)。我不知道如何启用 Phar one。

现在关于 C: xampp 中的文件本身,我转到 PHP 文件夹。在生产和开发 php.ini 文件下(安全比遗憾好) ,我有 allow_url_fopen=Onallow_url_include=On,并且我删除了分号,这样 extension=php_openssl.dll就不再被注释掉了。我甚至证实。Dll 位于 PHP 文件夹的 ext 文件夹中。Libeay32.dll 和 ssleay32.dll 都在 PHP 和 Apache 文件夹中。Apache 文件夹既不包含高效文件,也不包含开发 php.ini 文件。

为了安全起见,我转到 http://www.slproweb.com/products/Win32OpenSSL.html并安装了 Win32OpenSSLv1.0.0 d。

现在,我的 return _ website.php 中有问题的代码行如下所示:

$urlquery = "https://www.googleapis.com/customsearch/v1?key=".$appid."&cx=".$google_searchid."&q=".$query."&alt=atom&num=".$results;
$xmlresults = file_get_contents($urlquery);

我有两个其他网站,我查询,但他们是通过 HTTP 服务,他们的工作很好。我还在脚本末尾输入了这行代码:

echo 'openssl: ',  extension_loaded  ('openssl') ? 'yes':'no', "\n";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
echo 'wrappers: ', var_dump($w);

当我在 Eclipse 上以 PHP 脚本的形式运行它时,所有输出结果都按照我希望的方式完美地呈现出来:

openssl: yes
http wrapper: yes
https wrapper: yes
wrappers: array(10) {
[0]=>
string(5) "https"
[1]=>
string(4) "ftps"
[2]=>
string(3) "php"
[3]=>
string(4) "file"
[4]=>
string(4) "data"
[5]=>
string(4) "http"
[6]=>
string(3) "ftp"
[7]=>
string(13) "compress.zlib"
[8]=>
string(14) "compress.bzip2"
[9]=>
string(3) "zip"
}

尽管我做了这些修改(在我启动 Apache 之后) ,但是当我第一次通过 http://localhost/tutorial/retrieve_website.php访问 Eclipse 和 Firefox 中的 PHP 脚本时,仍然会得到相同的错误:

警告: file _ get _ content ()[ function. file-get-content ] : 无法找到包装器“ https”-在配置 PHP 时是否忘记启用它?在 C 语言中: xampp htdocs 教程在第29行检索 _ website.php

警告: file _ get _ content (https:// www.googleapis.com/customsearch/v1?key=abc0&cx=abc1&q=the+devil+went+down+to+georgia&alt=atom&num=5)[ function. file-get-content ] : 未能打开流: 在 C: xampp htdocs 中没有这样的文件或目录 警告: DOMDocument: : loadXML ()[ DOMDocument.loadXML ] : 在 C: xampp htdocs 教程中作为输入提供的空字符串在第33行 < br/> < br/> < br/> 检索 _ website.php Openssl: no http wrapper: yes https wrapper: no wrappers: array (10){[0] = > string (3)“ php”[1] = > string (4)“ file”[2] = > string (4)“ globb”[3] = > string (4)“ data”[4] = > string (4)“ http”[5] = > string (3)“ ftp”[6] = > string (3)“ zip”[7] = > string (13)“ press。“ zlib”[8] = > string (14)“ compress。Bzip2”[9] = > string (4)“ phar”}

我忽略了或者没有做到的是什么?据我所知,我已经做了所有关于 HTTPS 和 OpenSSL 的研究

265415 次浏览

您的 Apache 可能没有使用 SSL 支持进行编译。无论如何都要使用 cURL 而不是 file _ get _ content。试试这个代码,如果它失败了,那么我是对的。

function curl_get_contents($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}

在四处打探了一整天之后,我终于找到了答案,这多亏了这本指南: Http://piwigo.org/forum/viewtopic.php?id=15727

基本上在 Eclipse-> Windows-> Preferences-> PHP Executables 下面有一个关于。前任和。引用了 ini。在帮助菜单中安装 Eclipse Install New Software 中的 PHP Development Tools SDK Feature 时,默认的开发工具位于 Eclipse 目录中。

因此,我添加了一个名为 PHP5.3.5(CGI)的新可执行文件,并引用了 CGI.exe 和。Xampp 的 php 文件夹中的 ini。

谢谢你抽出时间来帮我。

在 XAMPP 中,我通过在 /apache/bin/php.ini 尽管如此 phpinfo ()中取消注释 ;extension=php_openssl.dll来解决这个问题,它告诉我 /php/php.ini是加载的 ini 文件。

编辑: 我想 Ezra 的回答是直接将扩展行添加到适当的 ini 文件的最佳解决方案。

我必须将 extension=php_openssl.dll添加到位于 xampp/php/php.iniphp.ini文件中。在添加了它并重新启动 Apache 之后,一切都很正常。

只需在 php.ini 文件中添加两行。

extension=php_openssl.dll
allow_url_include = On

对我很有效。

在我的例子中,问题是由于 WAMP 对 CLI 使用了不同于 Apache 的 php.ini,所以通过 WAMP 菜单进行的设置不适用于 CLI。只要修改 CLI php.ini 就可以了。

如果系统上安装了 curl,则可以使用此函数:

function get_url_contents($url){
if (function_exists('file_get_contents')) {
$result = @file_get_contents($url);
}
if ($result == '') {
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = curl_exec($ch);
curl_close($ch);
}


return $result;
}

在 OpenSuse 12.1中,唯一需要做的事情是:

zypper in php5-openssl

我已经启用了 openssl 扩展,它对我有效:)

扩展 = php _ openssl.dll

扩展名 = php _ openssl. dll

我也有这个错误。我发现我的 PHP 版本没有使用 openssl 编译,所以仅仅添加扩展指令到 PHP.ini 是不够的。我不知道在你的特殊情况下要如何解决这个问题,但对我来说,我使用 macport,命令就是:

sudo port install php5-openssl

对我来说,我不得不去掉 php.ini 中这些代码行的注释:

extension=php_openssl.dll
extension_dir = "ext"

如果 php _ openssl.dll 位于“ ext”文件夹中,则可以使用“ ext”。

注意: 我必须对 php.ini 文件的 执行此操作,否则它将无法工作。一个位于 vs.PHP 安装文件夹中,另一个位于 PHP 文件夹中

C:\Program Files (x86)\Jcx.Software\VS.Php\2013\Php 5.6
C:\Program Files (x86)\PHP\v5.6

来源

我正在使用 opsenSUSE Leap,我遇到了同样的问题——它意味着不支持 OpenSSL。我是这么解决的:

  1. 打开 YAST。
  2. 进入软件管理。
  3. 在左窗格的搜索框中,输入‘ php5-openssl’并按回车键。
  4. 单击右窗格中“ php5-OpenSSL”旁边的复选框以选择它,然后单击“ Accept”(这将添加 OpenSSL 支持)。
  5. 重新启动 Apache: sudo service apache2 restart

够了,你完了。

在 MAC AMPPS 上,我用以下内容更新了 php-5.5. ini,现在它可以工作了。

allow_url_include = On
extension=openssl.so

Simple _ html _ dom. php内部,将 $offset变量的值从 -1改为 0。 当迁移到 < em > PHP7时,通常会发生此错误。

HtmlDomParser::file_get_html使用 -1的默认偏移量,传入 0应该可以解决问题。

在 php.ini 文件中,在 extension=openssl之前删除“ ;”

对于那些使用 Winginx(基于 nginx 而不是基于 Apache)的用户,我通过以下4个步骤修复了它:

  1. 工具菜单上点击 Winginx PHP5配置(不用管名字里的 5...) :

    Winginx PHP5 Config

  2. 选择要更改 Php.ini的 PHP 版本:

    PHP version selection

  3. PHP 扩展选项卡上选择 Php _ openssl扩展并点击 保存按钮:

    php_openssl selection

  4. 通过任务栏(别说了开始)重新启动适当的 PHP 服务:

    Restart PHP service

对于请求 https 在视窗,file _ get _ content 有问题,取消 php.ini 文件中以下几行的注释:

extension=php_openssl.dll
extension_dir = "ext"

如果你正在使用 wamp 服务器,然后去图标点击这一点wamp server icon click on this

然后转到 PHP,然后点击 PHP 扩展,将有 PHP _ openssl 需要从那里激活,并重新启动 wamp 服务器active php_openssl from here

在我的例子中(在 Windows 上使用 FastCGI 模式的 PHP 7.3) ,它取消了 extension=openssl的注释。 不是 Extension = < strong > php _ openssl,正如大多数人在这里发布的。

(同样是 张贴在这里,但是没有关于操作系统的细节,这可能是一个关键的区别。)

在 Windows 上的 PHP 新版本中,这里的大多数答案都不起作用,因为相应的配置行已经更改。

对于 PHP 7.x,您需要取消注释(删除行首的 ;)以下几行:

extension_dir = "ext"
extension=openssl

我在 Windows 上尝试使用 phpcli 安装编曲器时出现了这个错误。为了解决这个问题,我只需要更改 php.ini中的扩展目录。我不得不删掉这句话:

; On windows:
extension_dir = "ext"

然后这一个和所有的事情工作

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;...
extension=openssl