CentOS的替代品Fedora Server实践
随着CentOS的停服,新系统不建议再使用CentOS了,建议使用其它兼容系统代替之。根据笔者的实践测试,现计划使用Fedora Server 替代Centos
一、为何选选择Fedora Server ?
作为redhat centos上游版本, 良好的兼容性。社区活跃度很高,生命周期稳定,软件包丰富。
二、版本选择
建议读者实际测试,自己的业务系统的在不同的版本上安装、运行的稳定性,从而得出最终结论。
三、我的选择
笔者的业务系统,主要为php 7.0/8.0, mysql 5.7/8.0, 实际测试 Fedora 35 是一个能较好兼容PHP 7/8的系统,fedora 36+因为软件包较新,很难兼容php 7/8的安装。
附安装日志:
对 php 7.4支持最好的Fedora版本为35,从Fedora 36开始,因为自带的libxml2,openssl版本过高,不能适配 php 7.4的编译,故解决办法有两种:
-
使用Fedora 35-, 安全兼容php 7.4
-
使用Fedora 36+,但需要源码编译指定版本的libxml,openssl, 工作量大,容易出错,不推荐
-
libxml报错
php-7.4.33/ext/libxml/libxml.c:826:17: warning: 'xmlRelaxNGCleanupTypes' is deprecated [-Wdeprecated-declarations]
xmlRelaxNGCleanupTypes();
php-7.4.33/ext/libxml/libxml.c:1050:49: error: passing argument 2 of 'xmlSetStructuredErrorFunc' from incompatible pointer type [-Wincompatible-pointer-types] xmlSetStructuredErrorFunc(NULL, php_libxml_structured_error_handler);
原因 php 7.4依赖的libxml版本最高为2.9.10, 但是操作系统自带的libxml版本为 3.x,所以安装失败。
参阅信息:https://www.php.net/manual/zh/libxml.installation.php#129004
查看系统安装的libxml的版本
[root@localhost ~]# rpm -qa | grep libxml2
libxml2-2.12.5-1.fc40.x86_64
python3-libxml2-2.12.5-1.fc40.x86_64
libxml2-devel-2.12.5-1.fc40.x86_64
显然系统自带版本为2.12,不能满足php 7.4的版本要求,故按上述参阅信息源码编译安装libxml2-2.9.10
下载源码,并编译安装到/usr/local/libxml2-2.9.10
wget https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.10.tar.xz
tar -xf libxml2-2.9.10.tar.xz
cd libxml2-2.9.10/
./configure --prefix=/usr/local/libxml2-2.9.10
make && make install
指定搜索路径
export PKG_CONFIG_PATH="/usr/local/libxml2-2.9.10/lib/pkgconfig:/lib64/pkgconfig"
- openssl报错
php-7.4.33/ext/openssl/openssl.c:5960:41: warning: passing argument 4 of 'RSA_public_decrypt' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
EVP_PKEY_get0_RSA(pkey),
warning: EVP_PKEY_get0_RSA is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
EVP_PKEY_get0_RSA(pkey),
版本安装说明:
https://www.php.net/manual/zh/openssl.requirements.php
https://www.php.net/manual/zh/openssl.installation.php
PHP 7.0 需要 OpenSSL >= 0.9.8。
PHP 7.1-8.0 需要 OpenSSL >= 1.0.1,< 3.0。
PHP >= 8.1 支持 OpenSSL >= 1.0.2,< 4.0。
查询系统已经安装的openssl版本
[root@localhost php-7.4.33]# rpm -qa | grep openssl
openssl-libs-3.2.1-2.fc40.x86_64
openssl-3.2.1-2.fc40.x86_64
openssl-devel-3.2.1-2.fc40.x86_64
但文档并未说明php-7.4对openssl的版本要求,我们根据以上线索,小于3.0版本应该可以兼容
下载地址 https://github.com/openssl/openssl/releases?page=1
查看版本列表,我们发现,openssl版本直接从1.1.1跳跌到3.0.x,其中并没有 2.x版本,故我们安装最新的1.1.1w
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
tar -xf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./Configure --prefix=/usr/local/openssl-1.1.1
NOTE: If in doubt, on Unix-ish systems use './config'.
./config --prefix=/usr/local/openssl-1.1.1
make && make install
export PKG_CONFIG_PATH="/usr/local/libxml2-2.9.10/lib/pkgconfig:/usr/local/openssl-1.1.1/lib64/pkgconfig/:/lib64/pkgconfig"

浙公网安备 33010602011771号