[英]Enabling SSL in Laragon for composer install, PHP 7.4
我知道这个问题在这个网站上到处都是,但所有的解决方案都不适用于我。
运行composer install时出现此错误:
In Factory.php line 650:
The openssl extension is required for SSL/TLS protection
but is not available. 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.
我不知道它从哪里得到 Factory.php 但它不在我的项目目录中。
我做了所有建议的解决方案。 我将 PHP 的 php.ini-development 文件重命名为 php.ini,并取消注释以下内容:
extension=openssl
因为我在 windows,这也是:
extension_dir = "ext"
我还通过 Laragon 菜单启用了 SSL > Apache > SSL > 启用
我的 php.ini 文件位于我的 laragon 文件夹中,如下所示:
C:\laragon\bin\php\PHP7\php.ini
然后我注意到一件事:当我右键单击 Laragon 的菜单和 go 到 php.ini 时,它说没有找到 php.ini 文件(即使它在正确的位置。)如所附照片所示。
当所有这些都不起作用时,我看到了另一个建议的解决方案,它说将 php.ini 文件也添加到 Laragon 中的 Apache 目录中,如下所示:
C:\laragon\bin\apache\httpd-2.4.54-win64-VS16\bin\php.ini
请注意,我每次都重新加载 Apache。
而且我仍然收到错误。
可能是什么问题? 我不想禁用 tls ,也不知道 Factory.php 文件是什么。
任何帮助表示赞赏。 谢谢。
更新:我找到了解决方案。 对于其他需要它的人:
这是我上面所做的一切,然后作为第一步,@Mihail Minkov 在解决“找不到文件”弹出窗口的答案中所说的内容。 但是为了解决 rest,我发现我的问题是,在我在 php.ini 中执行上述所有操作之前,我将 Laragon 使用的 php 版本 (v8) 切换为 v7.4(我一直试图获得的版本)工作。)出于某种原因,这使 Composer 感到困惑。 所以我不得不从我的计算机上卸载 Composer 本身并重新安装,但是这次通过在安装向导中选中它来激活开发者选项,因为我第一次没有。 在那之后,它起作用了。
我认为在这种情况下您缺少的是 PHP 实例的证书。
您可以直接从以下网址下载此证书文件: CURL 的站点
之后您需要做的是在php.ini文件中查找这些条目。 特别是[curl]
和 [curl] 之后的[openssl]
[curl]
。
您需要做的是将 cacert.pem 文件保存在您的 web 服务器根目录或您喜欢的目录中的某个位置,并使用绝对目录进行以下配置。
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "absolute location of where you saved the cacert.pem file"
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile= "absolute location of where you saved the cacert.pem file"
保存 php.ini 文件,重新启动服务器并重试。 这应该可以解决您的问题。
更新
如果你检查你的 PHP 信息phpinfo()
你应该有一个类似于这个的部分:
如果你不这样做,你可能没有启用 openssl。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.