centos8更换国内源及 Status code: 404 for https:// 问题
- 备份原来的配置文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
- 下载更新配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
- 更新缓存
yum makecache
- 可能由于版本更新,路径不存在出现404错误
- Status code: 404 for https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/ …
- Status code: 404 for https://mirrors.tuna.tsinghua.edu.cn/centos/8/BaseOS/x86_64/os/ …
- 查看对应的网站发现该路径不存在
到这个链接下https://mirrors.aliyun.com/centos/ 找到对应版本的路径,例如可以发现 https://mirrors.aliyun.com/centos/8/ 路径下没有BaseOS,需要替换为路径:https://mirrors.aliyun.com/centos/8-stream/
- 具体操作,使用命令 sed -i -e 将配置文件中所有 $releasever 全部替换为 $releasever-stream
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
# baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
baseurl=https://mirrors.aliyun.com/centos/$releasever-stream/BaseOS/$basearch/os/
- 再次更新缓存
yum makecache