在centos6.5上升级php-libxml版本到2.9.0

需求

应开发的需求,线上环境,php-libxml版本升级到2.8以上。

软件版本说明

当前系统,各软件版本:

php 5.6.15
libxml 2.7.6
glibc 2.12
zlib 1.2.3
xz-libs 4.999.9

升级步骤

1、安装工具集

yum groupinstall -y 'development tools'
yum install kernel-headers -y

2、解决安装libxml2-1.9.0版本时,遇到的依赖关系

1)升级glibc版本 ( 版本 > glibc-2.12 )

centos6系统,官方支持升级的最高版本是glibc-2.12(即yum升级支持的最高版本)。

wget http://ftp.redsleeve.org/pub/steam/glibc-2.15-60.el6.x86_64.rpm
wget http://ftp.redsleeve.org/pub/steam/glibc-devel-2.15-60.el6.x86_64.rpm
wget http://ftp.redsleeve.org/pub/steam/glibc-common-2.15-60.el6.x86_64.rpm
wget http://ftp.redsleeve.org/pub/steam/glibc-headers-2.15-60.el6.x86_64.rpm

rpm -Uvh glibc-2.15-60.el6.x86_64.rpm glibc-devel-2.15-60.el6.x86_64.rpm glibc-common-2.15-60.el6.x86_64.rpm glibc-headers-2.15-60.el6.x86_64.rpm

查看当前系统安装了glibc哪些包,以及最高支持版本:

# rpm -qa |grep glibc
glibc-2.15-60.el6.x86_64
glibc-common-2.15-60.el6.x86_64
glibc-devel-2.15-60.el6.x86_64
glibc-headers-2.15-60.el6.x86_64
# strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_PRIVATE

2)升级zlib版本 ( 版本 >= zlib-1.2.5 )

centos6系统,官方支持升级的最高版本是zlib-1.2.5。(即yum升级支持的最高版本)

wget http://ftp5.gwdg.de/pub/opensuse/repositories/home:/codice:/mono-redhat/CentOS_CentOS-6/x86_64/zlib-1.2.5-codice.4.1.x86_64.rpm
wget http://ftp5.gwdg.de/pub/opensuse/repositories/home:/codice:/mono-redhat/CentOS_CentOS-6/x86_64/zlib-devel-1.2.5-codice.4.1.x86_64.rpm
wget http://ftp5.gwdg.de/pub/opensuse/repositories/home:/codice:/mono-redhat/CentOS_CentOS-6/x86_64/zlib-static-1.2.5-codice.4.1.x86_64.rpm

rpm -Uvh zlib-1.2.5-codice.4.1.x86_64.rpm zlib-devel-1.2.5-codice.4.1.x86_64.rpm zlib-static-1.2.5-codice.4.1.x86_64.rpm

3)python2.7支持

centos6.5中,官方默认的Python版本为2.6。要装2.7版本,需要修改yum源。

yum install epel-release -y 
wget https://centos6.iuscommunity.org/ius-release.rpm
rpm -ivh ius-release.rpm
yum clean all 
yum install python27 -y

4)升级xz-libs版本 ( 版本 > xz-libs-4.9 )

centos6.5,官方yum升级的最高版本是4.999.9

wget http://ftp.redsleeve.org/pub/steam/xz-libs-5.0.5-1.el6.x86_64.rpm
wget http://ftp.redsleeve.org/pub/steam/xz-devel-5.0.5-1.el6.x86_64.rpm
wget http://ftp.redsleeve.org/pub/steam/xz-5.0.5-1.el6.x86_64.rpm
wget http://ftp.redsleeve.org/pub/steam/xz-lzma-compat-5.0.5-1.el6.x86_64.rpm
wget http://ftp.redsleeve.org/pub/steam/xz-compat-libs-5.0.5-1.el6.x86_64.rpm

rpm -Uvh xz-libs-5.0.5-1.el6.x86_64.rpm xz-devel-5.0.5-1.el6.x86_64.rpm xz-5.0.5-1.el6.x86_64.rpm  xz-lzma-compat-5.0.5-1.el6.x86_64.rpm xz-compat-libs-5.0.5-1.el6.x86_64.rpm

3、升级libxml2

wget http://xmlsoft.org/sources/libxml2-devel-2.9.0-0rc0.x86_64.rpm
wget http://xmlsoft.org/sources/libxml2-2.9.0-0rc0.x86_64.rpm
wget http://xmlsoft.org/sources/libxml2-python-2.9.0-0rc0.x86_64.rpm

rpm -Uvh libxml2-2.9.0-0rc0.x86_64.rpm libxml2-devel-2.9.0-0rc0.x86_64.rpm libxml2-python-2.9.0-0rc0.x86_64.rpm

4、重新编译php

需要重新编译php,使升级的php-libxml生效。

进入php5.6.15的源码目录,重新编译php:

# cd php-5.6.15
# ./configure  --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-bcmath=shared --with-pdo_sqlite --with-gettext=shared --with-iconv --enable-ftp=shared --with-sqlite --with-sqlite3 --enable-mbstring=shared --enable-sockets=shared --enable-zip --enable-soap=shared --with-openssl --with-zlib --with-curl=shared --with-gd=shared --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mcrypt=shared --with-mhash=shared --enable-opcache --with-mysql=mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --without-pear --with-libdir=lib64 --disable-fileinfo 
# make

替换生成的php、php-cgi程序文件:

# /etc/init.d/php-fpm stop
# mv /usr/local/php/bin/php /usr/local/php/bin/php.bak
# mv /usr/local/php/bin/php-cgi /usr/local/php/bin/php-cgi.bak
# cp -a sapi/cli/php /usr/local/php/bin/
# cp -a sapi/cgi/php-cgi  /usr/local/php/bin/
# /etc/init.d/php-fpm start

查看php-libxml版本升级是否生效:

# /usr/local/php/bin/php -i|grep libxml
libxml Version => 2.9.0
libxml
libxml2 Version => 2.9.0

后续补充

开启phpinfo访问,发现libxml版本仍是2.7.6。上述替换php、php-cgi程序的方法,是不能使得php-libxml版本升级生效的。
  需要重新编译安装php(不同安装目录),才会生效。

你可能感兴趣的:(在centos6.5上升级php-libxml版本到2.9.0)