Joh*_*n M 136 php apache xampp https openssl
问题在于问题.我已经对这方面的解决方案进行了彻底的调查,我知道有这方面的主题,我也跟着他们,没有任何工作.话虽这么说,我会列出到目前为止我所做的一切.我在Windows XP计算机上的最新Eclipse版本上使用Zend Debugging运行PHP 5.2.14.我有1 GB的RAM.我安装了运行Apache,MySQL和FileZilla的XAMPP.
在XAMPP上我做了以下操作(在这些更改期间Apache已关闭):从XAMPP控制面板单击Admin并转到https:// localhost/xampp/.从那里我在欢迎页面上接受了这一行的证书:
对于OpenSSL支持,请使用https:// 127.0.0.1或https:// localhost的测试证书.
在同一部分,我检查phpinfo().在"环境"下,SERVER["HTTPS"]是on.在'Apache Environment'下,HTTPS是On.在"PHP变量"下,_SERVER["HTTPS"]是On.在'Phar'下,OpenSSL support是disabled(安装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);
Run Code Online (Sandbox Code Playgroud)
我有两个其他网站,我查询,但他们通过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);
Run Code Online (Sandbox Code Playgroud)
当我在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"
}
Run Code Online (Sandbox Code Playgroud)
尽管我已经做了所有这些更改(在我启动Apache之后),但是当我第一次通过http://localhost/tutorial/retrieve_website.php访问Eclipse和Firefox中的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 = + Devil +去+下+ + + Georgia&alt = atom&num = 5)[function.file-get-contents]:无法打开流:第29行的C:\ xampp\htdocs\tutorial\retrieve_website.php中没有这样的文件或目录
警告: DOMDocument :: loadXML()[domdocument.loadxml]:在第33行的C:\ xampp\htdocs\tutorial\retrieve_website.php中作为输入提供的空字符串
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的所有研究
kje*_*ilh 177
我解决了它的XAMPP通过取消注释;extension=php_openssl.dll中/apache/bin/php.ini ,尽管 phpinfo()函数告诉我/php/php.ini是加载ini文件.
编辑:我猜Ezra答案是直接将扩展行添加到适当的ini文件的最佳解决方案.
Ezr*_*zra 97
我不得不添加extension=php_openssl.dll到我的php.ini文件中xampp/php/php.ini.不知何故它不存在,在添加它并重新启动Apache之后一切正常.
小智 32
只需在php.ini文件中添加两行.
extension=php_openssl.dll
allow_url_include = On
Run Code Online (Sandbox Code Playgroud)
它为我工作.
Dej*_*vic 18
您的Apache可能未使用SSL支持进行编译.无论如何,请使用cURL而不是file_get_contents.尝试这个代码,如果失败那么我是对的.
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;
}
Run Code Online (Sandbox Code Playgroud)
Kar*_*bwe 11
我在 Windows 上尝试使用 php cli 安装 Composer 时遇到此错误。为了解决这个问题,我只需要更改php.ini. 我不得不取消注释这一行:
; On windows:
extension_dir = "ext"
Run Code Online (Sandbox Code Playgroud)
然后这个和所有的事情都起作用了
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;...
extension=openssl
Run Code Online (Sandbox Code Playgroud)
在我的情况下,问题是由于WAMP使用不同于php的php.ini而不是Apache,因此通过WAMP菜单进行的设置不适用于CLI.只需修改CLI php.ini即可.
对我来说,我必须在php.ini中取消注释这些行:
extension=php_openssl.dll
extension_dir = "ext"
Run Code Online (Sandbox Code Playgroud)
如果php_openssl.dll位于"ext"文件夹中,则"ext"适用.
注意:我必须为我的两个 php.ini文件执行此操作,否则它将无法正常工作.一个位于vsphp安装文件夹中,另一个位于PHP文件夹中
C:\Program Files (x86)\Jcx.Software\VS.Php\2013\Php 5.6
C:\Program Files (x86)\PHP\v5.6
Run Code Online (Sandbox Code Playgroud)
在MAC AMPPS上,我用以下内容更新了php-5.5.ini,现在它可以工作了.
allow_url_include = On
extension=openssl.so
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
212885 次 |
| 最近记录: |