萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網路程式設計 >> PHP 程式設計

PHP 源码编译安装常见 configure 报错与 yum 包解决方案大全

核心原则

缺什么装什么:yum install -y xxx-devel。-devel 包包含编译所需的头文件与静态库。

高频报错对照表

完整推荐 configure 参数(生产常用)

./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www --with-fpm-group=www \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-pcntl \
--enable-sockets \
--enable-ftp \
--with-openssl \
--with-mhash \
--enable-zip \
--enable-soap \
--enable-opcache \
--with-sodium \
--with-password-argon2 \
--with-pear

编译加速技巧

# 并行编译 (CPU 核心数)
make -j$(nproc)

# 跳过测试套件 (节省时间)
# make test  # 可选,耗时较长

# 安装
make install

Docker 化构建(现代最佳实践)

# Dockerfile 片段
FROM php:8.3-fpm-alpine
RUN apk add --no-cache \
    libzip-dev libpng-dev libjpeg-turbo-dev freetype-dev \
    libxml2-dev curl-dev openssl-dev icu-dev oniguruma-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) \
    pdo_mysql mysqli bcmath gd intl zip opcache pcntl sockets
copyright © 萬盛學電腦網 all rights reserved
configure 报错关键词缺失库yum 安装命令
xslt-config not foundlibxsltyum -y install libxslt-devel
net-snmp-config not foundnet-snmpyum -y install net-snmp-devel
readline.h not foundreadlineyum -y install readline-devel
Cannot find pspellaspellyum -y install aspell-devel
ODBC header sqlext.h not foundunixODBCyum -y install unixODBC-devel
icu-config failedICUyum -y install libicu-devel
utf8_mime2text / U8T_CANONICALlibc-clientyum -y install libc-client-devel
freetype.h not foundfreetypeyum -y install freetype-devel
xpm.h not foundlibXpmyum -y install libXpm-devel
png.h not foundlibpngyum -y install libpng-devel
vpx_codec.h not foundlibvpxyum -y install libvpx-devel
Cannot find enchantenchantyum -y install enchant-devel
easy.h should be in /include/curllibcurlyum -y install libcurl-devel
mcrypt.h not foundlibmcryptyum -y install libmcrypt-devel (或手动编装 2.5.8)
Cannot find imaplibc-clientln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
Cannot find ldap.h / librariesopenldapyum -y install openldap-devel; cp -frp /usr/lib64/libldap* /usr/lib/
libpq-fe.h not foundpostgresqlyum -y install postgresql-devel
sqlite3 not foundsqliteyum -y install sqlite-devel
BZip2 not foundbzip2yum -y install bzip2-devel
DBA header filesdb4yum -y install db4-devel
jpeglib.h not foundlibjpegyum -y install libjpeg-devel
gmp.h not foundgmpyum -y install gmp-devel