centos 6和7 配置base源和epel源

本文详细介绍了如何配置CentOS 6与7使用阿里云YUM源的方法,包括备份原有repo文件,下载并替换为阿里云提供的repo文件,以及安装lrzsz和epel源的步骤。

首先把 /etc/yum.repos.d/  下所有文件新建个文件夹存放,或者重命名。

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

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

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

执行 yum clean all && yum list

如果报错,则修改repo文件把所有$releasever替换成6。

进入到上述目录下执行:

sed -i 's/\$releasever/6/' CentOS-Base.repo

重新更新源即可。

epel源下载的是rpm包,就先安装lrzsz软件,下载地址:http://mirrors.yun-idc.com/epel//6/x86_64/epel-release-6-8.noarch.rpm

yum install -y lrzsz

rz上传下载好的rpm,执行:

rpm -ivh epel-xxx.rpm  文件名自己补全。 然后清空缓存更新列表

执行 yum clean all && yum list。

 

centos7 配置阿里源

cd /etc/yum.repos.d

mkdir bak

mv * bak

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

yun clean all && yum list

CentOS 7 配置阿里云的 Yum EPEL (Extra Packages for Enterprise Linux) 可以帮助您获取更多的软件包,尤其是那些官方仓库未包含的扩展组件。以下是详细的步骤: **配置阿里云Yum**: 1. **首先备份原有repo文件**: ``` sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base-backup.repo ``` 2. **添加阿里云基础镜像**: - 打开 `vim` 编辑器编辑 `/etc/yum.repos.d/CentOS-Base.repo` 或者使用文本编辑器,如 `nano`: ``` nano /etc/yum.repos.d/CentOS-Base.repo ``` 添加以下内容到文件末尾(替换 `<YOUR-ALIYUN-MIRROR>` 为实际的镜像地址): ```bash [base] name=阿里云基础镜像 baseurl=<YOUR-ALIYUN-MIRROR>centos/7/os/x86_64/ gpgcheck=0 enabled=1 ``` 3. **保存并关闭编辑器**: - 如果使用 `vi` 或 `vim`, 输入 `:wq` 然后回车。 - 如果使用 `nano`, 按 `Ctrl+X`, 然后 `Y` 确认保存,最后 `Enter`。 4. **刷新缓存并安装新的yum**: ``` sudo yum clean all sudo yum makecache fast ``` **配置EPEL**: 1. **下载并安装 epel-release 包**: ``` wget https://mirrors.aliyun.com/epel/7/x86_64/epel-release-7-15.noarch.rpm sudo rpm -Uvh epel-release-7-15.noarch.rpm ``` 2. **检查是否安装成功**: ``` rpm -qa | grep epel-release ``` 3. **将EPEL添加到yum配置文件**: 同样打开或编辑 `/etc/yum.repos.d/epel.repo` 文件,然后添加以下行: ``` [epel] name=Extra Packages for Enterprise Linux 7 - $basearch mirrorlist=https://mirrors.aliyun.com/epel/7/$basearch/$basearch-repo-list.txt gpgcheck=1 gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7 enabled=1 ``` 4. **更新EPEL缓存安装新包**: ``` sudo yum update ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值