文章最后更新时间:2024年12月08日
由于CentOS官方已全面停止维护CentOS Linux项目,公告指出 CentOS7~8在2024年6月30日停止技术服务支持,导致CentOS系统源已全面失效,比如安装宝塔等等会出现网络不可达等报错,解决方案是更换系统源。以下介绍3种方式,帮助大家自行更换国内镜像yum源。
一、Curl方式更换阿里云镜像源
不知道自己系统版本的同学可以输入以下命令行查看CentOS版本
cat /etc/centos-release
CentOS 8
删除官方镜像源
rm /etc/yum.repos.d/CentOS-Stream-* -f
更换阿里云镜像源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
CentOS 7
删除官方镜像源
rm /etc/yum.repos.d/CentOS-Base.repo
更换阿里云镜像源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
最后执行测试命令,安装wget
yum install wget
对于海外云服务器,使用国内yum源可能会造成下载速度慢,推荐使用下面三条命令更新yum源。
cd /etc/yum.repos.d/ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
二、Wget安装更换阿里云yum源
#阿里云镜像 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #添加EPEL wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo #去除不存在的bazel镜像 yum-config-manager --disable bazel # 清理已下载安装包 yum clean all # 生成更新索引 yum makecache # 更新Centos系统软件包 yum update
如果提示以下错误:那么需要手动安装wget
-bash: wget: 未找到命令
wget安装
第一步:访问阿里云镜像站(https://developer.aliyun.com/packageSearch?word=wget),根据服务器架构选择所需版本,以wget-1.14-18.el7_6.1.x86_64.rpm为例,点击下载到本地;
第二步:在服务器/usr/local/下新建wget文件夹,将下载的wget安装包上传至该文件;
第三步:cd命令进入到这个wget目录下,再ls命令查看wget-1.14-18.el7_6.1.x86_64.rpm文件是否上传成功;
cd /usr/local/wget ls
第四步:执行如下命令,开始运行安装wget:
rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm
第五步:查看wget是否安装成功
rpm -qa|grep "wget"
第六步:更换阿里云yum
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
三、更换其它国内镜像源一键脚本命令
执行命令行
bash <(curl -sSL https://cdn.reo.ink/main.sh)
然后选择中国科技大学或者清华大学,一直按回车不要选Y。源更换完成后,即可正常安装软件。
文章版权声明:除非注明,否则均为0oD三一o0原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...