基础环境:

yum install -y gcc gcc-c++ make cmake \
    libxml2 libxml2-devel openssl openssl-devel \
    bzip2 bzip2-devel libcurl libcurl-devel \
    libjpeg libjpeg-devel libpng libpng-devel \
    freetype freetype-devel zlib zlib-devel \
    sqlite-devel readline-devel pkgconfig

这部分需要配置ISO本地源,剩下的就下载包在本地,包括:

PHP_TAR="php-8.3.30.tar.gz"                  
LIBMCRYPT_TAR="libmcrypt-2.5.8.tar.gz"
LIBZIP_TAR="libzip-1.9.2.tar.gz"
ONIG_TAR="onig-6.9.10.tar.gz"

主要遇到的问题:
1、yum不存在一些包

No match for argument: libmcrypt
No match for argument: libmcrypt-devel
Package zlib-1.2.11-17.1.ky10.aarch64 is already installed.
Package zlib-devel-1.2.11-17.1.ky10.aarch64 is already installed.
Package sqlite-devel-3.24.0-9.ky10.aarch64 is already installed.
No match for argument: oniguruma-devel
No match for argument: libzip
No match for argument: libzip-devel
Error: Unable to find a match: libmcrypt libmcrypt-devel oniguruma-devel libzip libzip-devel

解决办法就是:离线编译。

2、编译onig时,configure: error: cannot guess build type; you must specify one

解决办法:

编译onig时,在./configure命令后手动指定--build参数(适配 aarch64-linux-gnu 架构)

3、编译onig时,报错:ln: 无法创建符号链接 '/usr/include/onigposix.h': 文件已存在

解决办法:最后提供的脚本,兼容支持

4、编译libmcrypt报错:configure: error: cannot guess build type; you must specify one

===== 编译libmcrypt =====
checking build system type... ./config.guess: unable to guess system type

This script, last modified 2003-06-17, has failed to recognize
the operating system you are using. It is advised that you
download the most up to date version of the config scripts from

    ftp://ftp.gnu.org/pub/gnu/config/

If the version you run (./config.guess) is already up to date, please
send the following data and any information you think might be
pertinent to <config-patches@gnu.org> in order to provide the needed
information to handle your system.

config.guess timestamp = 2003-06-17

uname -m = aarch64
uname -r = 4.19.90-23.9.v2101.ky10.aarch64
uname -s = Linux
uname -v = #1 SMP Mon May 24 18:16:10 CST 2021

/usr/bin/uname -p = aarch64
/bin/uname -X     = 

hostinfo               = 
/bin/universe          = 
/usr/bin/arch -k       = 
/bin/arch              = aarch64
/usr/bin/oslevel       = 
/usr/convex/getsysinfo = 

UNAME_MACHINE = aarch64
UNAME_RELEASE = 4.19.90-23.9.v2101.ky10.aarch64
UNAME_SYSTEM  = Linux
UNAME_VERSION = #1 SMP Mon May 24 18:16:10 CST 2021
configure: error: cannot guess build type; you must specify one

解决办法:使用我这个脚本中下载的文件,脚本兼容了。libmcrypt-2.5.8自带的config.guess是 2003 年版本,远早于 ARM64/aarch64 架构的普及,无法自动识别 “鲲鹏 aarch64 + 麒麟 V10 Linux” 的系统组合,必须像处理onig一样,手动指定 build type。

config.guess:负责识别 “系统架构 + 系统类型”;
config.sub:负责验证 / 解析config.guess或手动指定的--build参数;
老旧的config.sub中没有 “aarch64” 这个架构的定义,因此即使手动指定--build=aarch64-linux-gnu,也会被判定为 “无效配置”。

5、oniguruma库检测失败的错误,核心原因是 PHP 的configure脚本通过pkg-config查找 onig 库,但你手动编译的 onig 库安装在/usr/local/onig(非系统默认路径),pkg-config无法自动找到其配置文件,导致判定 “oniguruma 未安装”。
报错:

checking whether to enable multibyte regex support (requires oniguruma)... yes
checking for oniguruma... no
configure: error: Package requirements (oniguruma) were not met:

Package 'oniguruma', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

解决办法:脚本兼容

最后是完整脚本及相关文件下载,不包含PHP的包,PHP的包很好找。解压后,直接sh kylin_php_install.sh 就可以了。

kylin_php_install.rar