windows 2011-4-28 10:58
CentOS 5.5 下將 PHP 5.1.6 更新到 5.2.10
CentOS 5.5 跟 CentOS 5.6 版內建的 PHP 版本都還是 5.1.6,對於有些OpenSource 的軟體都要求到 5.2.x 實在不夠,所以只能夠自行升級了...
方法如下:
修改檔案:/etc/yum.repos.d/CentOS-Base.repo
在檔案最後添加了以下設定
[quote]
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/5/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
[/quote]
上述設定網址都指向官方網站,可以放心更新 PHP。存檔後,下達更新命令:
[color=green]# yum update php*[/color]
更新完畢後以 PHP命令檢視版本:
[quote]
# php -v
PHP 5.2.10 (cli) (built: Nov 13 2009 11:24:03)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Zend Extension Manager v1.0.11, Copyright (c) 2003-2006, by Zend Technologies
with Zend Optimizer v3.2.0, Copyright (c) 1998-2006, by Zend Technologies
[/quote]
但升級之後發現,有時執行 php 的 program 時會出現以下 error
[quote]
PHP Warning: PHP Startup: fileinfo: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: Module 'readline' already loaded in Unknown on line 0
[/quote]
原因係 extension library 根本無 upgrade 過,所以要作出以下更新
[quote]
yum upgrade php-mcrypt
pecl install fileinfo readline memcache
pecl install imagick
pecl install readline
[/quote]
更新之後 readline extension還是會出現以下 Error
PHP Warning: Module [color=#006080]'readline'[/color] already loaded [color=#0000ff]in[/color] Unknown on line 0
可以到 /etc/php.d/readline.ini 裡面 將 “extension=readline.so” 這一句mark 掉
如下所示:
[quote]
; Enable readline extension module
; extension=readline.so
[/quote]
因為可能是 compile PHP 時已經直接 compile 在 readline 核心,這樣整個升級過程就都ok囉