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


當前系統,軟件版本說明:

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

 

需求:
  應開發的需求,線上環境,php-libxml版本升級到2.8以上。

升級步驟:
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(不同安裝目錄),才會生效。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM