如何给CentOS添加镜像源

如何给CentOS添加镜像源,第1张

下面以修改 CentOS 默认安装源为 阿里云为例进行说明:

1、备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、配置软件源

下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

3、生成缓存

yum makecache

1、首先我们根据自己使用的系统找到对应的软件库,例如我服务器的系统是Centos 6.5

2、yum源配置文件是放在/etc/yum.repos.d 这个目录下的

3、首先我们先看下服务器上面的yum源,可以参考一下相应的格式

4、我们可以参考这些文件的格式进行添加对应的yum源,不用强行记住这些配置,知道怎么配置即可我们创建一个yum源配置文件

5、然后往里边添加相应的内容

6、安装软件的时候即可看到我们自己添加上去的yum源了

1. 确认你的CentOS 的版本

首先通过以下命令确认你的CentOS 版本

$ cat /etc/RedHat-release

CentOS release 6.4 (Final)

2. 下载EPEL 的rpm 安装包

现在从上面的地址下载CentOS 版本所对应的EPEL 的版本

$ wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

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 文件。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/7700448.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-08
下一篇2023-04-08

发表评论

登录后才能评论

评论列表(0条)

    保存