php-7.1編譯記錄

編譯php-7.1.28步驟

  • 檢查環境
./configure \
--prefix=/u01/server/php-7.1.28 \
--enable-fpm \
--with-fpm-user=daemon \
--with-fpm-group=daemon \
--with-zlib-dir=/u01/server/common \
--enable-mbstring=all \
--enable-soap \
--enable-bcmath \
--enable-ftp \
--with-xmlrpc \
--enable-cgi \
--with-imap-ssl=/u01/server/common \
--with-png-dir=/u01/server/common \
--with-gd \
--with-zlib \
--with-curl=/u01/server/common \
--with-jpeg-dir=/u01/server/common \
--enable-exif \
--with-openssl=/u01/server/common \
--with-ldap=/u01/server/common \
--enable-calendar \
--enable-ctype \
--enable-pcntl \
--enable-session \
--with-bz2=/usr \
--enable-sockets \
--with-mcrypt=/u01/server/common \
--with-icu-dir=/u01/server/common \
--with-tidy=/u01/server/common \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo_sqlite=/u01/server/sqlite \
--with-sqlite3=/u01/server/sqlite \
--with-iconv=/u01/server/common \
--with-libxml-dir=/u01/server/common \
--with-xsl=/u01/server/common \
--with-freetype-dir=/u01/server/common \
--with-gmp=/u01/server/common \
--with-gettext \
--enable-intl \
--with-readline=/u01/server/common \
--enable-zip \
--with-libzip=/u01/server/common \
--disable-huge-code-pages
  • 編譯
make
  • 安裝
make install

備註

  • bz2 == bzip2是同一個意思
  • libzip提示不可用,google了好久也沒找到啥緣由,後面實在沒招了,硬着頭皮仔細看了configure腳本里面怎麼處理的,最終發現了一些蛛絲馬跡

碰到的問題

  • 問題1:gcc編譯工具問題
configure: error: in `/root/php-7.1.28':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
  • 解決方法
yum install glibc-headers gcc-c++
  • 問題2:提示libzip版本太低php

  • 解決方法html

安裝新版本的libzip yum自帶的不行,編譯安裝libzip-1.3.0版本
yum install libzip-devel.x86_64
yum remove libzip -y
  • 問題3:libzip檢查失敗
checking for zip_open in -lzip... no
configure: error: could not find usable libzip
  • 問題定位
  • 分析./configure腳本,發現最終會執行以下
$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5

cc -o conftest \
-I/u01/server/common/include -g -O2 -fvisibility=hidden \
-Wl,-rpath,/u01/server/common/lib -L/u01/server/common/lib -L/u01/server/common/lib -Wl,-rpath,/u01/server/common/lib -L/u01/server/common/lib -Wl,-rpath,/u01/server/sqlite/lib -L/u01/server/sqlite/lib -Wl,-rpath,/bitnami/ruby24stack-linux-x64/output/sqlite/lib -L/bitnami/ruby24stack-linux-x64/output/sqlite/lib -Wl,-rpath,/bitnami/ruby24stack-linux-x64/output/ImageMagick/lib -L/bitnami/ruby24stack-linux-x64/output/ImageMagick/lib  \
conftest.c \
-lzip -lz -lexslt -ltidy -lresolv -lcrypt -lreadline -lrt -lsqlite3 -lmcrypt -lltdl -lldap -llber -lstdc++ -liconv -lgmp -lpng -lz -ljpeg -lcrypto -lssl -lcrypto -lcurl -lbz2 -lz -lsqlite3 -lcrypto -lssl -lcrypto -lrt -lm -ldl -lnsl -lxml2 -lz -liconv -lm -ldl -lcurl -lxml2 -lz -liconv -lm -ldl -lfreetype -lz -lbz2 -ldl -lm -licui18n -licuuc -licudata -ldl -lm -licuio -lxml2 -lz -liconv -lm -ldl -lxml2 -lz -liconv -lm -ldl -lcrypt -lxml2 -lz -liconv -lm -ldl -lxml2 -lz -liconv -lm -ldl -lxml2 -lz -liconv -lm -ldl -lxml2 -lz -liconv -lm -ldl -lxslt -lxml2 -lz -liconv -ldl -lm
  • 執行這個提示tidy這個庫不存在
  • 源碼編譯tidy庫後,這個問題解決
 
  • 問題4:off_t類型未定義
configure: error: off_t undefined; check your library configuration
  • 解決方法
# 添加搜索路徑到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v
  • 問題5:autoconf時提示一些宏不存在
[root@localhost libzip]# autoconf
configure.ac:6: error: possibly undefined macro: AM_INIT_AUTOMAKE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:21: error: possibly undefined macro: AM_PROG_CC_C_O
configure.ac:109: error: possibly undefined macro: AM_CONDITIONAL
  • 解決方法
[root@localhost libzip]# autoreconf --install

參考資料

相關文章
相關標籤/搜索