
1. 在修改前先备份该文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2. 修改更新源配置文件(CentOS6地址,其他版本类似)
vim打开配置文件:
vim /etc/yum.repos.d/CentOS-Base.repo
复制以下内容粘贴到配置文件中进行:
# 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
baseurl=http://mirrors.oschina.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.oschina.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[addons]
name=CentOS-$releasever - Addons
baseurl=http://mirrors.oschina.com/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.oschina.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.oschina.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
最后保存配置文件。
3. 更新yum源配置
yum update
1. 确认你的CentOS 的版本首先通过以下命令确认你的CentOS 版本
$ cat /etc/redhat-release CentOS release 6.4 (Final)
2. 下载EPEL 的rpm 安装包
现在从上面的地址下载CentOS 版本所对应的EPEL 的版本
$ wget
3. 安装EPEL
通过以下命令安装EPEL 软件包
$ sudo rpm -ivh epel-release-6-8.noarch.rpm
或
$ sudo rpm -ivh epel-release*
5. 检查EPEL 源
安装好EPEL 源后,用yum 命令来检查是否添加到源列表
# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.vonline.vn * epel: buaya.klas.or.id * extras: centos-hn.viettelidc.com.vn * updates: mirrors.fibo.vn repo idrepo name status base CentOS-6 - Base 6,381 epel Extra Packages for Enterprise Linux 6 - x86_64 10,023 extras CentOS-6 - Extras 13 nginx nginx repo 47 updatesCentOS-6 - Updates 1,555 repolist: 18,019
EPEL已经在repo 后列出,并且显示提供了上万个软件包,所以EPEL 已经安装到你的CentOS了。
EPEL源的配置安装到了 /etc/yum.repos.d/epel.repo 文件。
现在来试一下从EPEL 获取软件包
$ sudo yum install htop
1、更换 yum 源的原因
国外网站连接响应太慢
国内 yum 源响应速度快
2、国内 yum 源
阿里云 yum 源
清华大学 yum 源
中科大 yum 源
网易 yum 源
3、更换清华大学 yum 源
1)建议先备份 CentOS-Base.repo
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
然后编辑 /etc/yum.repos.d/CentOS-Base.repo 文件,在以 mirrorlist= 开头的行前面加 # 注释掉;
并将以 baseurl= 开头的行取消注释(如果被注释的话),把该行内的域名(例如mirror.centos.org)替换为 mirrors.tuna.tsinghua.edu.cn。
2)实际 *** 作
[root@shell ~]#
[root@shell ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[root@shell ~]#
[root@shell ~]# vi /etc/yum.repos.d/CentOS-Base.repo
修改说明:
yum源配置总共有4项,但是更改方式都一样。都是将每一小块以“mirrorlist=”开头的那一行注释掉,然后将每一小块以“baseurl= ”开头的那一行前面的注释取消,最后将每一小块以“baseurl= ”开头的那一行内的centos官方域名(mirror.centos.org)更换为清华大学的域名(mirrors.tuna.tsinghua.edu.cn)即可
清华大学 yum 源配置实例:
[root@shell ~]#
[root@shell ~]# yum clean all #清空yum缓存
[root@shell ~]# yum makecache #更新yum源缓存
[root@shell ~]# yum repolist
[root@shell ~]#
[root@shell ~]# yum list httpd mariadb php
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)