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

需求

應(yīng)開發(fā)的需求,線上環(huán)境,php-libxml版本升級到2.8以上。

軟件版本說明

當前系統(tǒng),各軟件版本:

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版本時,遇到的依賴關(guān)系

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

centos6系統(tǒng),官方支持升級的最高版本是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

查看當前系統(tǒng)安裝了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系統(tǒng),官方支持升級的最高版本是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,官方y(tǒng)um升級的最高版本是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

后續(xù)補充

開啟phpinfo訪問,發(fā)現(xiàn)libxml版本仍是2.7.6。上述替換php、php-cgi程序的方法,是不能使得php-libxml版本升級生效的。
  需要重新編譯安裝php(不同安裝目錄),才會生效。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容