SuSE 10 编译 PHP-5.6.30
有几台旧机器,用的是原来腾讯开放平台上的腾讯改过的 SuSE 10:
Linux VM_suse 2.6.32.57-tlinux_xenU-1.1.rc8-state #1 SMP Wed Feb 20 15:07:57 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
原先用的 PHP 版本是 5.4.41,现在需要升级到 5.6.30。
编译选项:
./configure --prefix=/usr/local/php \
--with-mysqli \
--with-mysql \
--with-config-file-scan-dir=/etc/php \
--enable-pdo \
--with-pdo-mysql \
--with-iconv-dir=/usr/local \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-jpeg-dir \
--enable-gd-native-ttf \
--with-png-dir \
--enable-zip \
--with-zlib \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--with-curl \
--enable-mbstring \
--with-mcrypt \
--disable-ipv6 \
--enable-sockets \
--enable-soap \
--with-pcre-regex \
--with-gd \
--with-mhash \
--with-bz2 \
--with-libxml-dir \
--enable-gd-jis-conv \
--enable-pcntl \
--enable-xml \
--enable-inline-optimization \
--enable-maintainer-zts \
--with-unixODBC=/usr/ \
--with-curl=/usr/local/curl-7.46.0 \
--enable-opcache
这是从公司 wiki 上拷贝下来的,在 CentOS 6.2 上编译没有问题。不过在这腾讯版的 SuSE 10 上编译呢,简直就是各种坑。
开始折腾吧。
bison
configure 过程中出现了 warning:
# 没保留下来,大概是这个意思
WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 3.0, min: 204, excluded: 3.0).
从网上资料得知:
PHP 5.4: 1.28, 1.35, 1.75, 1.875, 2.0, 2.1, 2.2, 2.3, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.5, 2.5.1, 2.6, 2.6.1, 2.6.2, 2.6.4
PHP 5.5: 2.4, 2.4.1, 2.4.2, 2.4.3, 2.5, 2.5.1, 2.6, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7
PHP 5.6: 2.4 or later, excluding 3.0 only (3.0.1 and later are OK)
PHP 7.0: 2.4 or later
而系统上的 bison 版本是 2.1,所以需要升级 bison。
随便找了个 bison-2.7 打算编译,结果在 configure 过程中又提示要升级 automake 还是 m4 来着,好吧,换个低点的版本。
结果用了 PHP 5.6 的最低版本要求:bison-2.4,编译安装,这时 PHP 5.6 再 configure,没有上面的 warning 了。
各种 devel 包
就是在 configure 过程中,过不去了,就挨个进行安装,大概是缺了这些,不太记得了:
zypper in unixODBC unixODBC-devel libxml2-devel openssl-devel libjpeg-devel libpng-devel freetype2-devel libmcrypt-devel
skipping incompatible
configure 正常了,开始编译,过了一段时间后,出现了这样的报错:
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libcrypt.so when searching for -lcrypt
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libcrypt.a when searching for -lcrypt
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libz.so when searching for -lz
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libz.a when searching for -lz
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libresolv.so when searching for -lresolv
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libresolv.a when searching for -lresolv
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libcrypt.so when searching for -lcrypt
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/libcrypt.a when searching for -lcrypt
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/librt.so when searching for -lrt
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr//lib/librt.a when searching for -lrt
/usr/lib/libltdl.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
这是 64 位的系统,咋去找 32 位的库呢。
查看了 /etc/ld.so.conf
/usr/X11R6/lib64/Xaw3d
/usr/X11R6/lib64
/usr/X11R6/lib/Xaw3d
/usr/X11R6/lib
/usr/x86_64-suse-linux/lib
/usr/local/lib
/opt/kde3/lib
/opt/gnome/lib
/lib64
/lib
/usr/lib64
/usr/lib
/usr/local/lib64
/opt/kde3/lib64
/opt/gnome/lib64
/usr/local/mysql/lib
include /etc/ld.so.conf.d/*.conf
64 位的在 32 位之前,没问题啊!
无奈之下 make clean 然后重新 configure 之后,然后打开了 Makefile,将所有 -L/usr/lib 或者 -L/usr/local/lib 都修改为 -L/usr/lib64 或者 -L/usr/local/lib64
重新开始编译。
libidn.la
结果还是在原来的地方出错了,但是报错变成了:
libtool: link: cannot find the library `/usr/lib64/libidn.la' or unhandled argument `/usr/lib64/libidn.la'
make: *** [sapi/cli/php] Error 1
这里相当考验人,因为你很可能会以为是你刚刚的修改不 work,然后又改回去重新折腾。
其实这里是缺了一个 devel 包:libidn-devel
# ll /usr/lib64/libidn.la
/bin/ls: /usr/lib64/libidn.la: No such file or directory
# zypper in libidn-devel
Downloading: [S2:1][package]libidn-devel-0.6.0-14.2.x86_64, 1.1 M(4.3 M unpacked)
Installing: [S2:1][package]libidn-devel-0.6.0-14.2.x86_64
# ll /usr/lib64/libidn.la
-rw-r--r-- 1 root root 788 2006-06-17 01:05 /usr/lib64/libidn.la
curl
接下来是处理 curl,需要 7.46.0 这个版本,下载下来编译安装:
./configure --prefix=/usr/local/curl-7.46.0 && make -j2 && make install
重新编译 PHP,结果还报错:
ext/curl/.libs/interface.o: In function `zif_curl_pause':
/dist/dist/php-5.6.30/ext/curl/interface.c:3534: undefined reference to `curl_easy_pause'
ext/curl/.libs/interface.o: In function `zif_curl_unescape':
/dist/dist/php-5.6.30/ext/curl/interface.c:3509: undefined reference to `curl_easy_unescape'
ext/curl/.libs/interface.o: In function `zif_curl_escape':
/dist/dist/php-5.6.30/ext/curl/interface.c:3481: undefined reference to `curl_easy_escape'
ext/curl/.libs/multi.o: In function `_php_curl_multi_setopt':
/dist/dist/php-5.6.30/ext/curl/multi.c:397: undefined reference to `curl_multi_setopt'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
GREP 了一下:
# grep -r curl_easy_pause /usr/local/curl-7.46.0/include/*
/usr/local/curl-7.46.0/include/curl/curl.h: * NAME curl_easy_pause()
/usr/local/curl-7.46.0/include/curl/curl.h: * The curl_easy_pause function pauses or unpauses transfers. Select the new
/usr/local/curl-7.46.0/include/curl/curl.h:CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
是有定义的。那估计就是 configure 的时候没有正确设置 curl 目录了。
再看下 configure 选项,原来拷贝下来的配置,有两个 --with-curl:
--with-curl \
... 省略 ...
--with-curl=/usr/local/curl-7.46.0 \
... 省略 ...
再看 Makefile 确实没有 -I/usr/local/curl-7.46.0/include,按理说后面的配置会覆盖前面的,在 CentOS 6 上编译就没发生过问题,但是在 SuSE 10 就发生了。
去掉第一个 --with-curl 重新 configure 再编译,这回终于编译成功了。