如果沒有購買 Redhat 的服務, 或者服務已經過期, 在 Red Hat Enterprise Linux (RHEL) 用 yum 會出現以下錯誤:
|
1 2 3 4 5 6 7 |
# yum install pidgin Loaded plugins: rhnplugin, security This system is not registered with RHN. RHN support will be disabled. Setting up Install Process No package pidgin available. Nothing to do |
如果不想購買 Redhat 的服務, 可以很直接轉用 CentOS Repository, 而且做法十分簡單。
首先建立 CentOS Repository 的檔案:
|
1 |
# vi /etc/yum.repos.d/CentOS.repo |
然後加入以下一行內容, 要留意的是, 以下是以 RHEL 6 為例子, 如果是其他 RHEL 版本, 例如 RHEL 7, 需要將下面的 “6” 改為 “7”.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[CentOS6 base] name=CentOS-6-Base mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [CentOS6 updates] name=CentOS-6-Updates mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [CentOS5plus] name=CentOS-6-Plus mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [centos] name=CentOS $releasever - $basearch baseurl=http://ftp.heanet.ie/pub/centos/6/os/$basearch/ enabled=1 gpgcheck=0 |
然後將 RHEL Repository 停用, 開啟檔案 /etc/yum.repos.d/RHEL-Base.repo, 將檔案內所有 enabled 改為 0, 即是:
|
1 |
enabled=1 |
改為
|
1 |
enabled=0 |
接著匯入 CentOS 的 GPG key, 以下同樣以 RHEL 為例子:
|
1 |
# rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 |
然後就可以用 yum 透過 CentOS Repository 更新及安裝套件了。