1. 程式人生 > >Centos6.9配置163的yum源

Centos6.9配置163的yum源

yum配置163的yum源(Centos6.9為例)

yum安裝需要訪問外網,因此需要檢視DNS是否配置好,和防火牆是否關閉。

下載163的repo檔案

先進入到放yum原始檔的目錄,需要root使用者
cd /etc/yum.repos.d
下載repo檔案
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

編輯yum源repo檔案
把檔案裡面的$releasever全部替換為版本號: 6.9(先不用替換,如果不行再替換試試),如果系統變數有$releasever這個變數,那麼就不需要替換。
yum中$releasever、 $basearch等變數含義

vim CentOS6-Base-163.repo
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/6.9/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6.9/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6.9/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6.9/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6.9/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

清理並重建快取(很重要)

yum clean all
yum makecache fast

測試yum源是否可用

yum -y install gcc