BloggerAds

2011年5月14日 星期六

CentOS 5.5中PHP升級至 5.3的方法

因為json_decode這個function 只在php 5.2以後支援,而CentOS 5.5 中的php卻只有5.1,官方的yum更新也還沒推出,所以在php升級這一塊,就得另外想辦法。

在參考google大神的意見之後,升級至5.3版最簡單的方法大概是這個吧:
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh epel-release-5*.rpm
rpm -Uvh remi-release-5*.rpm 
yum -y --enablerepo=remi update php-\*

若你的MySQL沒有升級,還是5.0版的話,上列命令執行後,會出現衝突的錯誤,錯誤訊息如下:
Transaction Check Error:
  file /etc/my.cnf from install of mysql-libs-5.5.12-1.el5.remi.i386 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.5.12-1.el5.remi.i386 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.5.12-1.el5.remi.i386 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386

看到上面這個錯誤訊息,其實也不用將mysql移除再重裝,直接執行下面的命令去更新mysql到最新版本即可,而且會連php、php-mysql都更新成5.3.6。
yum -y --enablerepo=remi update mysql-\*

參考資料:
http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&t=19416
http://blog.wu-boy.com/2009/09/rhelinstalling-php-52x-or-53x-on-redhat-es5-centos-5/

沒有留言:

張貼留言