phpbrew install 8.0.11 時會出現 OpenSSL 的錯誤訊息:
/home/zero/.phpbrew/build/8.0.29/ext/openssl/xp_ssl.c:1240:9: warning: ‘DH_free’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
1240 | DH_free(dh);
| ^~~~~~~
In file included from /usr/include/openssl/dsa.h:51,
from /usr/include/openssl/x509.h:37,
from /usr/include/openssl/ssl.h:31,
from /home/zero/.phpbrew/build/8.0.29/ext/openssl/xp_ssl.c:31:
/usr/include/openssl/dh.h:200:28: note: declared here
200 | OSSL_DEPRECATEDIN_3_0 void DH_free(DH *dh);
| ^~~~~~~
主要是因為舊版的 PHP 使用到的 OpenSSL 也是舊版的。
解決方法:
- 編譯、安裝舊版 OpenSSL (v1.1)
- 自訂 pkgconfig 來跑 phpbrew install
先下載 OpenSSL v1.1,並編譯:
cd ~/tmp/openssl-1.1.1v # --prefix 設定為暫存路徑 ./Configure --prefix=/home/zeroplex/openssl-1.1.1/ -fPIC -shared linux-x86_64 make make install
make install 後執行檔、函式庫就會存放到 /home/zeroplex/openssl 中。
先設定要使用的 OpenSSL pkgconfig:
# 在 openssl 位置中找到 pkgconfig 的路徑 export PKG_CONFIG_PATH=/home/zeroplex/openssl/lib/pkgconfig
接下來 phpbrew 使用相同的指令即可:
phpbrew install 8.0.29 +defaults
備註:phpbrew install 7.4 也需要相同的方法

