萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Linux 教學

新手入門:RHEL5/CentOS 5 配置 YUM 軟體源完整步驟(含鏡像源、GPG 金鑰、測試驗證)

一、確認 YUM 已安裝

若未安裝,透過 RPM 手動部署:rpm -ivh yum-*.rpm

二、編輯倉庫配置檔

cd /etc/yum.repos.d/
vi CentOS-Base.repo

寫入官方鏡像源(以上海交通大學鏡像為例)

[base]
name=CentOS-5 - Base
baseurl=https://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=1
gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-centos5

[update]
name=CentOS-5 - Updates
baseurl=https://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-centos5

[addons]
name=CentOS-5 - Addons
baseurl=https://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-centos5

[extras]
name=CentOS-5 - Extras
baseurl=https://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-centos5

[centosplus]
name=CentOS-5 - Plus
baseurl=https://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-centos5

[contrib]
name=CentOS-5 - Contrib
baseurl=https://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-centos5

新增 DAG 第三方倉庫

[dag]
name=Dag RPM Repository for RHEL5
baseurl=https://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=1
gpgkey=https://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt

三、匯入 GPG 金鑰驗證套件完整性

rpm --import https://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5

四、測試驗證

yum update

若成功列出可更新套件清單,即表示 YUM 源配置完成,可正常安裝/更新軟體。

關鍵參數說明

  • $basearch:自動匹配系統架構(i386/x86_64 等)
  • gpgcheck=1:啟用 GPG 簽名驗證,保障套件完整性
  • enabled=0:預設停用該倉庫(如 centosplus、contrib),需時手動 --enablerepo 啟用
copyright © 萬盛學電腦網 all rights reserved