Rocky Linux 9 与Centos区别,以及软件安装dnf命令
2026-04-25 12:09 xiashengwang 阅读(0) 评论(0) 收藏 举报参考:
这2篇博客讲解的很清楚,可以查阅
Rocky Linux系列(一):dnf命令详解
Rocky Linux(二):CentOS与Rocky 命令区别
安装Rocky Linux后,主要要换几个国内的软件仓库。
2. Rocky 官方源 一键换国内镜像(必做,避免慢 / 超时)
备份原有 repo(防止改错)
bash
cp -r /etc/yum.repos.d /etc/yum.repos.d.bak
替换为阿里云镜像(Rocky9,最稳)
sed -e 's|^mirrorlist=|#mirrorlist=|g' \-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \-i.bak \/etc/yum.repos.d/rocky*.repo
如果换源报https认证错误,可以更新下:
sudo dnf update ca-certificates
其他国内镜像(备用)
- 腾讯云:https://mirrors.cloud.tencent.com/rocky/
- 清华大学:https://mirrors.tuna.tsinghua.edu.cn/rockylinux
- 华为云:https://mirrors.huaweicloud.com/rockylinux
- 中科大:https://mirrors.ustc.edu.cn/rockylinux
刷新缓存(必须做)
dnf clean all && dnf makecache
EPEL 源 换国内镜像(第三方必备)
EPEL 是装 nginx、htop、git、redis 等的核心第三方源,默认国外,换国内:
方法一:
直接安装阿里云提供的epel(推荐,不用手动替换源)
sudo dnf install -y https://mirrors.aliyun.com/epel/epel-release-latest-9.noarch.rpm
方法二:
通过系统包管理器安装
# 安装EPEL(自动配置)
sudo dnf config-manager --set-enabled crb
dnf install -y epel-release
# 替换EPEL为阿里云镜像
sed -e 's|^metalink=|#metalink=|g' \-e 's|^#baseurl=https://download.fedoraproject.org/pub/epel|baseurl=https://mirrors.aliyun.com/epel|g' \-i.bak \/etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
# 刷新缓存
dnf clean all && dnf makecache
