我們知道CentOS由yum通過/etc/yum.repos.d/CentOS-Base.repo裡的配置進行鏡像伺服器尋找更新,最近給客戶安裝一個MANTIS和TESTLINK組建的測試平台,發現CentOS內建PHP是5.1版本,不支援最新的phpMyAdmin和TESTLINK,這兩個應用的最新版本都需要5.2或更高版本的PHP環境。
在網上查閱相關資料後發現,其實CentOS團隊還維護著一個測試更新庫,這裡有許多“測試”版應用(暫僅這麼稱呼著,我的理解是因種種原因沒有正式對外發行而已),經過簡單的修改就可以得到以下設定檔:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[testing]
name=CentOS-$releasever - Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
可以在設定檔最後增加一個[testing] 節,注意這個配置節和它上面系統內建的兩個配置節設定了參數enabled=0 ,平時我們執行yum upgrade時並不會被檢查,只有通過適當變通,我們才可能通過這些庫尋找或更新更多應用(因為CentOS團隊沒有正式對外發行,所以建議只在“迫不得已”的情況下使用),例如我要安裝最新的php,在控制台執行以下命令,yum就會發現並提示是否要安裝5.2.9-2版本的PHP:
yum install php --disablerepo=/* --enablerepo=testing
注意後兩個參數的使用,屏蔽了其它更新庫的使用,開啟了測試更新庫,通過這種方式找到了5.2版本的PHP,正是我需要的;其實通過這種方式還可以找到更高版本的MySQL和Apache Http Server等,不過要不要更新全由你自己決定了。 :)