在最近的 PHP CVE 的問題下, 需要來更新一下環境, 原本執行在 PHP 7.4 的環境已於 2022/11/3 也已停止支援更新了, 所以來更新一下新的 PHP版本.
目前已修復的版本如下:
- PHP 8.5.12
- PHP 8.4.27
- PHP 8.3.36
- PHP 8.2.35
於是下載了更新的 XAMPP, PHP版本為 8.4.27, 不過剛裝後好, 有個小問題在使用 curl無法成功, 檢查了一下, 在啟用 curl 後(extension=curl), 仍無法在 PHP程式中成功使用 curl_init() 函數, 檢查了一下 error.log 發現(在windows下的 event log也會出現):
PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: C:\\xampp\\php\\ext\\curl (The specified module could not be found), C:\\xampp\\php\\ext\\php_curl.dll (The specified module could not be found)) in Unknown on line 0
所以即使在 c:\xampp\php\ext\ 下有 php_curl.dll 檔, 仍然出現這個問題, 查找了一下這個 php_curl.dll 還需要依存以下幾個在 apache 下就要載入的動態函式庫:
- libssh2.dll
- libcrypto-3-x64.dll
- libssl-3-x64.dll
- nghttp2.dll
- brotlidec.dll
內容是放在 C:\xampp\apache\conf\extra\httpd-xampp.conf 中, 請自行加入以下內容:
#for php_curl start LoadFile "C:/xampp/php/libssh2.dll" LoadFile "C:/xampp/php/libcrypto-3-x64.dll" LoadFile "C:/xampp/php/libssl-3-x64.dll" LoadFile "C:/xampp/php/nghttp2.dll" LoadFile "C:/xampp/php/brotlidec.dll" #for php_curl end
如此便能正常使用 curl 了, 可以利用 php_info() 或是 curl_init() 來進行檢查即可. (error.log 中也沒有這個啟動的錯誤 log了)
-- viewing this page|-- online sitewide