CentOS7和 8配置阿里云yum源和epel源

素颜马尾好姑娘i 2022-11-05 06:22 656阅读 0赞

首先先要确定你的Linux CentOS 版本(7和8的镜像不一样):

查看 CentOS版本命令:

  1. cat /etc/redhat-release

在这里插入图片描述

在这里插入图片描述

文章目录

    • 一、CentOS7 / 8 通用
    • 二、CentOS8

一、CentOS7 / 8 通用

1、进入yum源配置目录

  1. cd /etc/yum.repos.d

2、 建议备份先原先的yum源

  1. 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版本执行以下命令:

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

(2)假如是8版本执行以下命令:

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

由于我此时我演示的机器的Centos7,我就是执行了7版本的命令了(上面一条命令)
在这里插入图片描述

方式二:更新为搜狐的源

  1. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

方式三:更新为163的源

  1. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo

4、清空并生成缓存

  1. yum clean all
  2. yum makecache

在这里插入图片描述
5、查看一下

  1. yum repolist

在这里插入图片描述

二、CentOS8

2、进去 yum.repos.d 目录。

  1. cd /etc/yum.repos.d

3、编辑文件一:CentOS-AppStream.repo

  1. 通用修改配置文件常用命令:
  2. vim properties_name # 打开指定文件
  3. i a # 进入写模式
  4. ESC # 退出写模式
  5. :wq # 保存修改并退出
  6. :q! # 不保存修改退出

使用vim进入编辑文件,先按 i 键或 a 键进入编辑模式,添加完成后,按Esc键退出编辑模式,最后在英文状态下输入 :wq 保存并退出文件。

  1. vim CentOS-AppStream.repo

将一下信息添加近文件:

  1. baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/

在这里插入图片描述
4、编辑文件二: CentOS-Base.repo

  1. vim CentOS-Base.repo
  2. baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/

5、编辑文件三: CentOS-Extras.repo

  1. vim CentOS-Extras.repo
  2. baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/

在这里插入图片描述
6、清空一下之前的依赖 记住:下载有可能会慢,但是只要没有报错就等待就行

  1. yum clean all

7、缓存一下

  1. yum makecake

8、查看一下是否是 8

  1. yum repolist

9、下载epel源

  1. yum install epel-release

10、全部更新一下

  1. yum update

到此已经完成!希望对你有用


有用点个关注,手留余香!

发表评论

表情:
评论列表 (有 0 条评论,656人围观)

还没有评论,来说两句吧...

相关阅读