php SSL/TLS 保护需要 openssl 扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35249620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The openssl extension is required for SSL/TLS protection
提问by Yang
composer create-project flarum/flarum . --stability=beta
I try to run this command, but it gave me this error.
我尝试运行此命令,但它给了我这个错误。
[RuntimeException]
The openssl extension is required for SSL/TLS protection but is not availab
le. If you can not enable the openssl extension, you can disable this error
, at your own risk, by setting the 'disable-tls' option to true.
I tried to add "extension=php_openssl.dll" to "php.ini", but it still got this error
我尝试将“extension=php_openssl.dll”添加到“php.ini”,但仍然出现此错误
回答by Vinícius Medeiros
The same error occurred to me. I fixed it by turning off TLS for Composer, it's not safebut I assumed the risk on my develop machine.
同样的错误发生在我身上。我通过关闭 Composer 的 TLS 来修复它,这不安全,但我承担了我的开发机器上的风险。
try this:
尝试这个:
composer config -g -- disable-tls true
and re-run your Composer. It works to me!
并重新运行您的 Composer。它对我有用!
But it's unsecure and not recommended for your Server. The official website says:
但它不安全,不推荐用于您的 Server。官网说:
If set to true all HTTPS URLs will be tried with HTTP instead and no network-level encryption is performed. Enabling this is a security risk and is NOT recommended. The better way is to enable the php_openssl extension in php.ini.
如果设置为 true,所有 HTTPS URL 将改为使用 HTTP 尝试,并且不执行网络级加密。启用此功能存在安全风险,不建议使用。更好的方法是在 php.ini 中启用 php_openssl 扩展。
If you don't want to enable unsecure layer in your machine/server, then setup your php to enable openssl and it also works. Make sure the PHP Openssl extension has been installed and enable it on php.ini file.
如果你不想在你的机器/服务器中启用不安全层,那么设置你的 php 以启用 openssl 并且它也可以工作。确保已安装 PHP Openssl 扩展并在 php.ini 文件中启用它。
To enable OpenSSL, add or find and uncomment this line on your php.ini file:
要启用 OpenSSL,请在 php.ini 文件中添加或查找并取消注释此行:
Linux/OSx:
Linux/OSx:
extension=php_openssl.so
Windows:
视窗:
extension=php_openssl.dll
And reload your php-fpm / web-server if needed!
如果需要,请重新加载您的 php-fpm / web-server!
回答by Martin Zeitler
according to the composer referencethere are two relevant options: disable-tls
and secure-http
.
根据作曲家参考,有两个相关选项:disable-tls
和secure-http
.
nano ~/.composer/config.json
...
nano ~/.composer/config.json
...
{
"config": {
"disable-tls": true,
"secure-http": false
}
}
then it complains much:
然后它抱怨很多:
You are running Composer with SSL/TLS protection disabled.
Warning: Accessing getcomposer.org over http which is an insecure protocol.
but it performs the composer selfupdate
(or whatever).
但它执行composer selfupdate
(或其他)。
while one cannot simply "enable SSL in the php.ini" on Linux; PHP needs to be compiled with openSSL configured as shared
library - in order to be able to access it from the PHP CLI SAPI.
而不能简单地在 Linux 上“在 php.ini 中启用 SSL”;PHP 需要使用配置为shared
库的openSSL 进行编译- 以便能够从PHP CLI SAPI访问它。
回答by NiceDevelopmentq
I had the exact same problem and couldn't find a solution, so after thinking and looking for a while I figured that my PHP.INI apparently didn't look in the correct directory for my PHP Extensions, so I went under:
我遇到了完全相同的问题并且找不到解决方案,所以经过思考和寻找一段时间后,我发现我的 PHP.INI 显然没有在我的 PHP 扩展的正确目录中查找,所以我继续:
"Directory in which the loadable extensions (modules) reside." And found the following:
“可加载扩展(模块)所在的目录。” 并发现以下内容:
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
;extension_dir = "ext"
And simply removed the ; infront of "extension_dir = "ext", note this is only for Windows, remove the semicolon in front of the first extension_dir if you are running a different operating system.
并简单地删除了; "extension_dir = "ext" 前面,注意这仅适用于 Windows,如果您运行的是不同的操作系统,请删除第一个 extension_dir 前面的分号。
I have no idea why mine wasn't already unmarked, but it's just something to look for if you are having problems.
我不知道为什么我的还没有被标记,但是如果您遇到问题,这只是需要寻找的东西。
回答by Clairton Luz
To enable openssl go into php.ini and enable this line:
要启用 openssl 进入 php.ini 并启用这一行:
extension=php_openssl.dll
if you don't want enable openssl you can set to composer not use openssl with this command:
如果您不想启用 openssl,您可以使用以下命令设置为 composer not use openssl:
composer config -g -- disable-tls true
however, this is a security problem.
然而,这是一个安全问题。
回答by Vrushal Raut
This issue occurs due to openssl and extension director so uncomment below extensions in php.ini
file
出现此问题是由于 openssl 和 extension Director 所以取消注释php.ini
文件中的扩展名
extension=php_openssl.dll
extension=php_openssl.dll
extension_dir = "ext"
extension_dir = "ext"
Its works on my machine.
它在我的机器上工作。
回答by Michael Neely
I had the same problem. I tried everything listed on this page. When I re-installed Composer it worked like before. I had a PHP version mismatch that was corrected with a new install establishing the dependencies with the PHP path installed in my system environment variables.
我有同样的问题。我尝试了此页面上列出的所有内容。当我重新安装 Composer 时,它像以前一样工作。我有一个 PHP 版本不匹配,通过新安装得到纠正,使用安装在我的系统环境变量中的 PHP 路径建立依赖关系。
I DO NOT RECOMMEND the composer config -g -- disable-tls true
approach.
我不推荐这种composer config -g -- disable-tls true
方法。
By the way the way to reverse this is composer config -g -- disable-tls false
.
顺便说一下,扭转这种局面的方法是composer config -g -- disable-tls false
。
回答by Qriz75
For me on Windows 10 none of those worked ... I had changed my local server from WAMP to Laragon and had to add the new path to the php.ini in the Environment Variables under:
对于我在 Windows 10 上,这些都不起作用......我已经将我的本地服务器从 WAMP 更改为 Laragon,并且必须在环境变量下添加到 php.ini 的新路径:
Control Panel --> Advanced System Settings --> Environment Variables --> Path (double click) --> Browse... then navigate to the php.ini and click ok.
控制面板 --> 高级系统设置 --> 环境变量 --> 路径(双击)--> 浏览...然后导航到 php.ini 并单击确定。
After that a reboot was needed and now composer works like a charm!
之后需要重新启动,现在作曲家的工作就像一个魅力!