mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
279 字
1 分钟
CentOS7配置阿里云镜像源(超详细过程)
2024-06-01

前言#

此方法亲测有效,适用于CentOS7版本所有的环境。 CentOS7本地yum源的配置,请参考本人的另一篇博客文章:https://blog.csdn.net/KingveyLee/article/details/114979418 RedHat7本地yum源的配置,请参考本人的另一篇博客文章:https://blog.csdn.net/KingveyLee/article/details/114981036

一、环境准备#

你需要准备一台干净的CentOS7的环境,且可以ping的通外网~尤其是mirrors.aliyun.com。 简单测试一下,如果通的话,再执行以下步骤完成设置。

ping mirrors.aliyun.com
1

二、手动配置阿里云源#

  1. 备份官方的原yum源的配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
1
  1. 下载Centos-7.repo文件

最小化安装,如果没有wget的命令,可使用curl代替wget,执行如下语句代替: curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1
  1. 清除及生成缓存。
# 清除yum缓存
yum clean all
# 缓存阿里云源
yum makecache
# 测试阿里云源
yum list
123456

三、脚本配置本地源#

  1. 找个目录,创建脚本文件:

本人以/root/目录为例

vi /root/auto_aliyun.sh
1
  1. 编写如下内容:
#!/bin/bash
# 备份官方的原yum源的配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 下载Centos-7.repo文件,或者curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo,取决于你是否有wget的命令
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 清除yum缓存
yum clean all
# 缓存本地yum源
yum makecache
12345678910
  1. 按ESC。输入保存,完成镜像阿里云源的脚本文件的编写
  2. 赋予脚本可执行的权限
chmod +x /root/auto_aliyun.sh
1
  1. 执行脚本文件,即可
/root/auto_aliyun.sh
分享

如果这篇文章对你有帮助,欢迎分享给更多人!

CentOS7配置阿里云镜像源(超详细过程)
https://6wd.cn/posts/centos7-aliyun-mirror/
作者
技术宅拯救世界!
发布于
2024-06-01
许可协议
CC BY-NC-SA 4.0

部分信息可能已经过时

目录