[英]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.