首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 網頁程式設計 >> PHP 程式設計 >> PHP 相關知識

PHP 編譯安裝常見 configure 錯誤與 yum 解決方案速查表

     編輯:PHP 相關知識

PHP 編譯安裝常見 configure 錯誤與 yum 解決方案速查表

PHP 源碼編譯時 ./configure 階段頻繁報缺少開發庫頭文件。本文匯總高頻錯誤與對應 yum install *-devel 解決命令,覆蓋 XML、圖像、數據庫、加密、郵件、LDAP、ODBC、SNMP、XSLT 等常見依賴,適合 CentOS/RHEL 系統快速排查。

速查表

錯誤信息關鍵字缺失開發包安裝命令
xslt-config not found / libxsltlibxslt-develyum -y install libxslt-devel
net-snmp-config not foundnet-snmp-develyum -y install net-snmp-devel
readline.h not foundreadline-develyum -y install readline-devel
Cannot find pspellaspell-develyum -y install aspell-devel
ODBC header sqlext.h not foundunixODBC-develyum -y install unixODBC-devel
ICU prefix / icu-config failedlibicu-develyum -y install libicu-devel
utf8_mime2text / U8T_CANONICALlibc-client-develyum -y install libc-client-devel
freetype.h not foundfreetype-develyum -y install freetype-devel
xpm.h not foundlibXpm-develyum -y install libXpm-devel
png.h not foundlibpng-develyum -y install libpng-devel
vpx_codec.h not foundlibvpx-develyum -y install libvpx-devel
Cannot find enchantenchant-develyum -y install enchant-devel
libcurl / easy.h not foundlibcurl-develyum -y install libcurl-devel
mcrypt.h not foundlibmcrypt-devel (需源碼編裝)wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz && tar zxf ... && ./configure && make && make install
Cannot find imaplibc-client-devel + 軟鏈yum -y install libc-client-devel && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
Cannot find ldap.h / ldap librariesopenldap-develyum -y install openldap openldap-devel && cp -frp /usr/lib64/libldap* /usr/lib/
libpq-fe.h not foundpostgresql-develyum -y install postgresql-devel
sqlite3 not foundsqlite-develyum -y install sqlite-devel
BZip2 not foundbzip2-develyum -y install bzip2-devel
DBA header files not founddb4-develyum -y install db4-devel
jpeglib.h not foundlibjpeg-develyum -y install libjpeg-devel
gmp.h not foundgmp-develyum -y install gmp-devel
xml2-config not foundlibxml2-develyum -y install libxml2-devel
pcre.h not foundpcre-develyum -y install pcre-devel
MySQL header files not foundmysql-develyum -y install mysql-devel

通用排查技巧

  1. 查看 config.log:tail -50 config.log 定位具體缺失頭文件/庫路徑。
  2. 搜尋文件:find /usr -name "xxx.h" 確認文件是否存在但路徑不在默認搜尋目錄。
  3. 指定路徑:./configure --with-xxx-dir=/custom/path 強制指定庫目錄。
  4. 安裝開發工具組:yum groupinstall "Development Tools" 確保 gcc、make、autoconf 等基礎工具齊全。
  5. EPEL 源:yum install epel-release 獲取更多第三方庫包。

典型完整編譯參數示例

./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--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 \
--with-mcrypt \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--enable-opcache \
--with-xsl \
--with-ldap \
--with-ldap-sasl

收藏此表,下次編譯 PHP 遇到 configure 報錯,一鍵 yum 解決,事半功倍。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved