CentOS7和 8配置阿里云yum源和epel源
首先先要确定你的Linux CentOS 版本(7和8的镜像不一样):
查看 CentOS版本命令:
cat /etc/redhat-release
文章目录
- 一、CentOS7 / 8 通用
- 二、CentOS8
一、CentOS7 / 8 通用
1、进入yum源配置目录
cd /etc/yum.repos.d
2、 建议备份先原先的yum源
mv CentOS-Base.repo CentOS-Base.repo.bk
3、下载新版的CentOS-Base.repo
方法一:更新为阿里云的源(推荐)
阿里云官方镜像站: https://developer.aliyun.com/special/mirrors/notice
根据你的Centos版本的7和8 来选择执行以下wget命令
(1)假如是7版本执行以下命令:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
(2)假如是8版本执行以下命令:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
由于我此时我演示的机器的Centos7,我就是执行了7版本的命令了(上面一条命令)
方式二:更新为搜狐的源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
方式三:更新为163的源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
4、清空并生成缓存
yum clean all
yum makecache
5、查看一下
yum repolist
二、CentOS8
2、进去 yum.repos.d 目录。
cd /etc/yum.repos.d
3、编辑文件一:CentOS-AppStream.repo
通用修改配置文件常用命令:
vim properties_name # 打开指定文件
i 或 a 键 # 进入写模式
ESC 键 # 退出写模式
:wq # 保存修改并退出
:q! # 不保存修改退出
使用vim进入编辑文件,先按 i
键或 a
键进入编辑模式,添加完成后,按Esc
键退出编辑模式,最后在英文状态下输入 :wq
保存并退出文件。
vim CentOS-AppStream.repo
将一下信息添加近文件:
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
4、编辑文件二: CentOS-Base.repo
vim CentOS-Base.repo
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
5、编辑文件三: CentOS-Extras.repo
vim CentOS-Extras.repo
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
6、清空一下之前的依赖 记住:下载有可能会慢,但是只要没有报错就等待就行
yum clean all
7、缓存一下
yum makecake
8、查看一下是否是 8
yum repolist
9、下载epel源
yum install epel-release
10、全部更新一下
yum update
到此已经完成!希望对你有用
有用点个关注,手留余香!
还没有评论,来说两句吧...