问题就在问题里。我已经对与此相关的解决方案进行了彻底的调查,我知道有一些主题,我也遵循了它们,但没有任何效果。话虽这么说,我将列出迄今为止我所做的一切。我在 Windows XP 计算机上的最新 Eclipse 版本上运行 PHP 5.2.14 和 Zend 调试。我有 1 GB 内存。我运行 XAMPP,并安装了 Apache、MySQL 和 FileZilla。
在 XAMPP 上,我做了以下操作(Apache 在这些更改期间关闭):
在 XAMPP 控制面板中单击Admin,然后转到 https:// localhost/xampp/
。从那里我接受了欢迎页面上这一行的证书:
要获得 OpenSSL 支持,请使用带有 https://127.0.0.1 或 https://localhost 的测试证书。
在同一部分,我检查了 phpinfo()
。在“环境”下,SERVER["HTTPS"]
已开启
。在“Apache 环境”下,HTTPS
为开启
。在“PHP 变量”下,_SERVER["HTTPS"]
为开启
。在“Phar”下,OpenSSL 支持
被禁用
(安装 ext/openssl)。我不知道如何启用 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 文件。
我已经访问 http://www.slproweb.com/products/Win32OpenSSL.html 并安装了 Win32 OpenSSL v1.0.0d 用于安全措施。
现在,我的retrieve_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/ 在 Eclipse 和 Firefox 中访问 PHP 脚本时,我仍然遇到相同的错误retrieve_website.php:
警告:file_get_contents() [function.file-get-contents]:无法找到包装器“https” - 您在配置 PHP 时是否忘记启用它?在 C:\xampp\htdocs\tutorial\retrieve_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:\xampp\htdocs\tutorial\retrieve_website 中没有这样的文件或目录。 php 第 29 行
警告: DOMDocument::loadXML() [domdocument.loadxml]:第 33 行 C:\xampp\htdocs\tutorial\retrieve_website.php 中提供的空字符串作为输入
openssl: 没有 http 包装器: 是 https 包装器: 没有包装器: array(10) { [0]=>;字符串(3)“php”[1]=>字符串(4)“文件”[2]==>字符串(4)“glob”[3]==>字符串(4)“数据”[4]=>字符串(4)“http”[5]=>字符串(3)“ftp”[6]==>字符串(3)“zip”[7]=>字符串(13)“compress.zlib”[8]=>字符串(14)“压缩.bzip2”[9]=>字符串(4)“phar”}
我忽略或未能做到什么?据我所知,我已经完成了有关 HTTPS 和 OpenSSL 的所有研究
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.
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:
For OpenSSL support please use the test certificate with https:// 127.0.0.1 or https:// localhost.
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.
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.
I've went to http://www.slproweb.com/products/Win32OpenSSL.html and installed Win32 OpenSSL v1.0.0d for safe measure.
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);
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', "\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);
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"
}
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:
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:\xampp\htdocs\tutorial\retrieve_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:\xampp\htdocs\tutorial\retrieve_website.php on line 29
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Empty string supplied as input in C:\xampp\htdocs\tutorial\retrieve_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" }
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
发布评论
评论(23)
我在 Windows 上也遇到了类似的问题。在
php.ini
中启用extension=openssl
和extension_dir = "ext"
行不足以解决问题。我还必须将
C:\php\
文件夹添加到 Windows 环境路径。这是因为 openssl 模块需要加载一些位于 php 安装文件夹中的 dll(例如:libcrypto)。
在解决此问题时对我有帮助的是检查
\apache24\logs\
文件夹中的error.log
文件。如果无法加载 openssl 模块,您将收到明确的消息。I had similar issue on Windows. Enabling the
extension=openssl
andextension_dir = "ext"
lines inphp.ini
, was not enough to fix the issue.I also had to add the
C:\php\
folder to Windows environment path.This is because openssl module need to load some dlls (eg: libcrypto) which are located in php installation folder.
What helped me while troubleshooting this was to check the
error.log
file in\apache24\logs\
folder. There you will get explicit messages if openssl module cannot be loaded.我对
https
请求也遇到了类似的问题,在弄乱了我的 php.ini 文件一段时间后,我尝试将链接更改为http
。只需更改下载链接即可使用,您不需要启用任何内容。人们对 PHP7 所做的更改可能有效,但我使用的是 PHP 8.3。如果有人知道如何修复 php.ini-development 和生产文件,我很乐意看到对此的评论!
I had a similar issue with the
https
request and after a little bit of time messing with my php.ini files I tried just changing the link tohttp
. It works just change the download link and you shouldn't need to enable anything.The changes that people made to PHP7 probably do work but I am using PHP 8.3. If someone know how to fix it for the php.ini-development and production files, I would love to see comments on it!
在 simple_html_dom.php 中,将
$offset
变量的值从-1
更改为0
。当您迁移到 PHP 7 时,通常会发生此错误。
HtmlDomParser::file_get_html
使用默认偏移量-1
,传入0
应该可以解决你的问题。Inside the simple_html_dom.php change the value of the
$offset
variable from-1
to0
.this error usually happens when you migrate to PHP 7.
HtmlDomParser::file_get_html
uses a default offset of-1
, passing in0
should fix your problem.PHP7,在php.ini文件中,去掉“;”在
extension=openssl
之前PHP7, in php.ini file, remove the ";" before
extension=openssl
对我来说,我必须取消 php.ini 中这些行的注释:
如果 php_openssl.dll 位于“ext”文件夹中,则“ext”适用。
注意:我必须对我的两个 php.ini 文件执行此操作,否则它将无法工作。一个位于 vs.php 安装文件夹中,另一个位于 PHP 文件夹
来源
For me I had to uncomment these lines in php.ini:
"ext" is applicable if php_openssl.dll is located in the "ext" folder.
Note: I had to do this for two of my php.ini files otherwise it would not work. One located in the vs.php installation folder, and the other on on the PHP folder
Source
在 Windows 上较新版本的 PHP 上,此处的大多数答案都不起作用,因为相应的配置行已更改。
对于 PHP 7.x,您需要取消注释(删除行开头的
;
)以下行:extension_dir = "ext"
扩展名=openssl
On newer versions of PHP on Windows, the majority of answers here won't work, since the corresponding configuration lines have changed.
For PHP 7.x, you need to uncomment (remove the
;
at the beginning of the line) the following lines:extension_dir = "ext"
extension=openssl
Windows 中 https 请求的 file_get_contents 出现问题,请取消注释 php.ini 文件中的以下行:
Problem with file_get_contents for the requests https in Windows, uncomment the following lines in the php.ini file:
如果您的系统上安装了curl,您可以使用此函数:
You can use this function instead if curl is installed on your system:
经过一整天的窥探,我通过本指南找到了答案:
http://piwigo.org/forum/viewtopic.php?id=15727
基本上在Eclipse下->窗口 ->首选项-> PHP 可执行文件,有一节介绍了 .exe 和 .ini 的引用位置。当您通过 Eclipse 的“帮助”菜单中的“安装新软件”安装 PHP 开发工具 SDK 功能时,默认的目录位于 Eclipse 目录中。
因此,我添加了一个名为 PHP 5.3.5 (CGI) 的新可执行文件,并引用了 xampp 的 php 文件夹中的 cgi.exe 和 .ini。
感谢 webarto 抽出时间来帮助我。
After snooping around all day, I figured out the answer thanks to this guide:
http://piwigo.org/forum/viewtopic.php?id=15727
Basically under Eclipse -> Windows -> Preferences -> PHP Executables, there is a section on where the .exe and .ini is referenced. The defaulted ones were in the Eclipse directory when you install the PHP Development Tools SDK Feature from Eclipses Install New Software in the Help menu.
So instead of that, I added a new executable called PHP 5.3.5 (CGI) and referenced the cgi.exe and .ini from xampp's php folder.
Thank you webarto for giving your time to help me out.
我正在使用 opsenSUSE Leap,并且遇到了同样的问题 - 这意味着不支持 OpenSSL。我是这样解决的:
sudo service apache2 restart
就这样,你就完成了。
I'm using opsenSUSE Leap, and I had the same issue -- it means there's no support for OpenSSL. This is how I resolved it:
sudo service apache2 restart
That's it, you're done.
我也遇到这个错误。我发现我的 PHP 版本没有编译 openssl,所以简单地将扩展指令添加到 php.ini 是不够的。我不知道在你的特定情况下你必须如何解决这个问题,但对我来说,我使用 macports,命令只是:
I got this error too. I figured out that my version of PHP didn't have openssl compiled in, so simply adding the extension directive to php.ini wasn't enough. I don't know how you have to solve this in your particular case, but for me, I use macports, and the command was just:
对于那些使用 Winginx(基于 nginx 而不是基于 Apache)的人,我通过以下 4 个步骤修复了它:
在工具菜单上点击Winginx PHP5配置(不用介意名称中的5...):
选择您想要 php.ini 更改的 PHP 版本:
关于 PHP扩展选项卡选择php_openssl扩展并点击保存按钮:
通过任务栏重新启动相应的 PHP 服务(停止和启动):
For those using Winginx (nginx based instead of Apache based), I fixed it with these 4 steps:
On the Tools menu hit the Winginx PHP5 Config (never mind the 5 in the name...):
Select the PHP version you want the php.ini to change:
On the PHP Extensions tab select the php_openssl extension and hit the Save button:
restart the appropriate PHP service through the taskbar (Stop and Start):
如果您使用的是 wamp 服务器,请转到图标,单击此
然后转到 PHP,然后单击 PHP 扩展,需要从那里激活 php_openssl 并重新启动 wamp 服务器 < /a>
If you are using wamp server then go to icon click on this
Then go to PHP then click on PHP extension there would be php_openssl need to activate from there and restart wamp server
您的 Apache 编译时可能不支持 SSL。无论如何,使用 cURL 而不是 file_get_contents 。尝试这个代码,如果失败那么我是对的。
Your Apache is probably not compiled with SSL support. Use cURL instead of file_get_contents anyway. Try this code, if it fails then I am right.
我已经启用了 openssl 扩展,它对我有用:)
;extension=php_openssl.dll
到
extension=php_openssl.dll
I have enable the openssl extention and it work for me :)
;extension=php_openssl.dll
to
extension=php_openssl.dll
我在 Windows 上尝试使用 php cli 安装 Composer 时遇到此错误。为了解决这个问题,我只需要更改 php.ini 中的扩展目录即可。我不得不取消注释这一行:
然后这个和所有的事情都起作用了
I got this error while attempting to install composer using php cli on Windows. To solve it, I just needed to change the extension directory in
php.ini
. I had to uncomment this line:Then this one and all things worked
就我而言(Windows 上的 PHP 7.3,FastCGI 模式),它取消了
extension=openssl
的注释。不像大多数人在这里发布的那样,extension=php_openssl。
(同样的事情发布在这里,但没有操作系统的详细信息,这可能是这里的一个关键区别。)
In my case (PHP 7.3 on Windows in FastCGI mode) it was uncommenting
extension=openssl
.Not extension=php_openssl, as most people post here.
(The same thing was posted here, but without details on OS which may be a key difference here.)
就我而言,问题是由于 WAMP 使用与 Apache 不同的 CLI php.ini,因此通过 WAMP 菜单进行的设置不适用于 CLI。只需修改 CLI php.ini 即可运行。
In my case, the issue was due to WAMP using a different php.ini for CLI than Apache, so your settings made through the WAMP menu don't apply to CLI. Just modify the CLI php.ini and it works.
在 OpenSuse 12.1 中,唯一需要的是:
in OpenSuse 12.1 the only thing required was:
在 MAC AMPPS 上,我使用以下内容更新了 php-5.5.ini,现在它可以工作了。
On MAC AMPPS, I updated the php-5.5.ini with the following and now it works.
我通过在
/apache/bin/php.ini
中取消注释;extension=php_openssl.dll
在 XAMPP 中解决了这个问题 尽管 phpinfo() 告诉我< code>/php/php.ini 是加载的ini文件。编辑:我想 Ezra 的答案是直接将扩展行添加到适当的 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.EDIT: I guess Ezra answer is the best solution directly adding the extension line to the appropriate ini file.
我必须将
extension=php_openssl.dll
添加到位于xampp/php/php.ini
的php.ini
文件中。不知怎的,它不在那里,添加它并重新启动 Apache 后一切工作正常。I had to add
extension=php_openssl.dll
to myphp.ini
file located inxampp/php/php.ini
. Somehow it was not there, after adding it and restarting Apache everything was working fine.只需在 php.ini 文件中添加两行即可。
它对我有用。
just add two lines in your php.ini file.
its working for me.