找不到包装器“https"- 你是不是在配置 PHP 时忘记启用它?
问题在于问题.我已经对这方面的解决方案进行了彻底的调查,我知道有一些主题,我也关注了它们,但没有任何效果.话虽如此,我将准确列出我迄今为止所做的一切.我在我的 Windows XP 计算机上的最新 Eclipse 版本上运行 PHP 5.2.14 和 Zend 调试.我有 1 GB 的 RAM.我安装了运行 Apache、MySQL 和 FileZilla 的 XAMPP.
The problem is in the question. I've done a thorough investigation for solutions in regards to this and I know there are topics to this and I've followed them too and nothing has worked. That being said I'll list out exactly everything I've done so far. I am running PHP 5.2.14 with Zend Debugging on the latest Eclipse version on my Windows XP computer. I have a 1 GB of RAM. I have XAMPP running with Apache, MySQL, and FileZilla installed.
在 XAMPP 上,我完成了以下操作(Apache 在这些更改期间关闭):从 XAMPP 控制面板单击 Admin 并转到 https://localhost/xampp/
.从那里我接受了欢迎页面上这一行的证书:
On XAMPP I've done the following (Apache was off during these changes):
Clicked on Admin from the XAMPP Control Panel and went to https:// localhost/xampp/
. From there I accepted the certs from this line on the welcome page:
对于 OpenSSL 支持,请使用带有 https://127.0.0.1 或 https://localhost 的测试证书.
For OpenSSL support please use the test certificate with https:// 127.0.0.1 or https:// localhost.
在同一部分,我检查了 phpinfo()
.在环境"下,SERVER["HTTPS"]
为 on
.在Apache 环境"下,HTTPS
为 On
.在PHP 变量"下,_SERVER["HTTPS"]
为 On
.在Phar"下,OpenSSL support
为 disabled
(安装 ext/openssl).我不知道如何启用 Phar one.
On that same section I checked phpinfo()
. Under 'Environment', SERVER["HTTPS"]
is on
. Under 'Apache Environment', HTTPS
is On
. Under 'PHP Variables, _SERVER["HTTPS"]
is On
. Under 'Phar', OpenSSL support
is disabled
(install ext/openssl). I don't know how to enable the Phar one.
现在关于 C:xampp 中的文件本身,我去了 PHP 文件夹.在生产和开发的 php.ini 文件下(比抱歉更安全),我有 allow_url_fopen=On
、allow_url_include=On
,并且我删除了分号,以便 extension=php_openssl.dll
不再被注释掉.我什至确认 .dll 位于 PHP 文件夹的 ext 文件夹中.libeay32.dll 和 ssleay32.dll 都在 PHP 和 Apache 文件夹中.Apache 文件夹不包含生产或开发 php.ini 文件.
Now regarding the files themselves in C:xampp, I went to the PHP folder. Under both production and development php.ini files (better safe than sorry), I have allow_url_fopen=On
, allow_url_include=On
, and I removed the semicolon, so that extension=php_openssl.dll
is no longer commented out. I even confirmed that the .dll is in the ext folder of the PHP folder. Both libeay32.dll and ssleay32.dll are in the PHP and Apache folders. The Apache folder doesn't contain either productive or development php.ini files.
我去过 http://www.slproweb.com/products/Win32OpenSSL.html 和为安全措施安装了 Win32 OpenSSL v1.0.0d.
I've went to http://www.slproweb.com/products/Win32OpenSSL.html and installed Win32 OpenSSL v1.0.0d for safe measure.
现在我的retrieve_website.php 中有问题的代码行如下所示:
Now the line of code in question in my retrieve_website.php looks like this:
$urlquery = "https://www.googleapis.com/customsearch/v1?key=".$appid."&cx=".$google_searchid."&q=".$query."&alt=atom&num=".$results;
$xmlresults = file_get_contents($urlquery);
我查询了另外两个网站,但它们是通过 HTTP 提供的,并且运行良好.我还在脚本末尾附近输入了这行代码:
I have two other websites that I query but they are served via HTTP and they work fine. I also have this line of code entered near the end of the script:
echo 'openssl: ', extension_loaded ('openssl') ? 'yes':'no', "
";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "
";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "
";
echo 'wrappers: ', var_dump($w);
当我在 Eclipse 上将它作为 PHP 脚本运行时,一切都按照我想要的方式完美输出以及这些结果:
When I run it as a PHP Script on Eclipse, everything outputs perfectly fine the way I want along with these results:
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:
Despite all these changes I've made (after I started up Apache), I still get the same errors the first time I access my PHP script in Eclipse and Firefox via http://localhost/tutorial/retrieve_website.php:
警告:file_get_contents() [function.file-get-contents]:无法找到包装器https" - 您在配置 PHP 时是否忘记启用它?在 C:xampphtdocs utorialetrieve_website.php 第 29 行
警告:file_get_contents(https://www.googleapis.com/customsearch/v1?key=已删除 API ID&cx=已删除搜索 ID&q=The+Devil+went+down+to+Georgia&alt=atom&num=5) [function.file-get-contents]:无法打开流:C:xampphtdocs utorialetrieve_website 中没有这样的文件或目录.php上线29
警告:DOMDocument::loadXML() [domdocument.loadxml]:在第 33 行的 C:xampphtdocs utorialetrieve_website.php 中作为输入提供了空字符串
openssl:没有 http 包装器:是 https 包装器:没有包装器:array(10) { [0]=> string(3) "php" [1]=> string(4) "file" [2]=> string(4) "glob" [3]=> string(4) "data" [4]=> string(4) "http" [5]=> string(3) "ftp" [6]=> string(3) "zip" [7]=> string(13) "compress.zlib" [8]=> string(14) "compress.bzip2" [9]=> string(4) "phar" }
Warning: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:xampphtdocs utorialetrieve_website.php on line 29
Warning: file_get_contents(https:// www.googleapis.com/customsearch/v1?key=removed API ID&cx=removed search ID&q=The+Devil+went+down+to+Georgia&alt=atom&num=5) [function.file-get-contents]: failed to open stream: No such file or directory in C:xampphtdocs utorialetrieve_website.php on line 29
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Empty string supplied as input in C:xampphtdocs utorialetrieve_website.php on line 33
openssl: no http wrapper: yes https wrapper: no wrappers: array(10) { [0]=> string(3) "php" [1]=> string(4) "file" [2]=> string(4) "glob" [3]=> string(4) "data" [4]=> string(4) "http" [5]=> string(3) "ftp" [6]=> string(3) "zip" [7]=> string(13) "compress.zlib" [8]=> string(14) "compress.bzip2" [9]=> string(4) "phar" }
什么是我忽略或未能做到的?据我所知,我已经完成了有关 HTTPS 和 OpenSSL 的所有研究
What is it that I have overlooked or failed to do? To my own knowledge, I've done everything that I've researched about concerning HTTPS and OpenSSL
推荐答案
我在 XAMPP 中通过取消注释 /apache/bin/php.ini 中的
尽管 phpinfo() 告诉我 ;extension=php_openssl.dll
解决了这个问题/php/php.ini
是加载的 ini 文件.
I solved it in XAMPP by uncommenting ;extension=php_openssl.dll
in /apache/bin/php.ini
despite phpinfo() telling me /php/php.ini
was the loaded ini file.
我猜 Ezra 的答案是直接将扩展行添加到适当的 ini 文件中的最佳解决方案.
I guess Ezra answer is the best solution directly adding the extension line to the appropriate ini file.
相关文章