如何更换安装源?这篇教程可以帮你
- 在无法连接到我们安装脚本的情况下,使用此脚本
- bash <(wget --no-check-certificate -qO- https://120.78.156.100/new/fix_source.sh)
- 可以连接到我们安装脚本,但是无法使用操作系统带的安装源,使用此脚本
- bash <(wget --no-check-certificate -qO- https://download.bt.cn/tools/fix_source.sh)
1、CentOS7 安装源更换为腾讯源:
①、备份当前的安装源
- \cp -rp /etc/yum.repos.d/ /etc/yum.repos.d_back
复制代码
下载腾讯云的安装源
- wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
复制代码
②、设置腾讯云的epel源
- wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
复制代码
操作完后使用下面的命令进行清理当前的yum缓存,并生成腾讯云的安装缓存
- yum clean all
- yum makecache
复制代码
2、Ubuntu系列安装源太老,请参考下面的清华源
3、Debian系列,只增加Debian9 和Debian10
备份Debian系列的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
复制代码
①Debian9.x (stretch)
- echo "" > /etc/apt/sources.list
复制代码
- cat > /etc/apt/sources.list<<EOF
- deb http://mirrors.cloud.tencent.com/debian stretch main contrib non-free
- deb http://mirrors.cloud.tencent.com/debian stretch-updates main contrib non-free
- #deb http://mirrors.cloud.tencent.com/debian stretch-backports main contrib non-free
- #deb http://mirrors.cloud.tencent.com/debian stretch-proposed-updates main contrib non-free
- deb-src http://mirrors.cloud.tencent.com/debian stretch main contrib non-free
- deb-src http://mirrors.cloud.tencent.com/debian stretch-updates main contrib non-free
- #deb-src http://mirrors.cloud.tencent.com/debian stretch-backports main contrib non-free
- #deb-src http://mirrors.cloud.tencent.com/debian stretch-proposed-updates main contrib non-free
- EOF
复制代码
②、debian10.x(buster)
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
复制代码
- echo "" > /etc/apt/sources.list
复制代码
- cat > /etc/apt/sources.list<<EOF
- deb https://mirrors.cloud.tencent.com/debian/ buster main contrib non-free
- deb https://mirrors.cloud.tencent.com/debian/ buster-updates main contrib non-free
- deb https://mirrors.cloud.tencent.com/debian/ buster-backports main contrib non-free
- deb https://mirrors.cloud.tencent.com/debian-security buster/updates main contrib non-free
- deb-src https://mirrors.cloud.tencent.com/debian/ buster main contrib non-free
- deb-src https://mirrors.cloud.tencent.com/debian/ buster-updates main contrib non-free
- deb-src https://mirrors.cloud.tencent.com/debian/ buster-backports main contrib non-free
- deb-src https://mirrors.cloud.tencent.com/debian-security buster/updates main contrib non-free
- EOF
复制代码
1、CentOS7:
①先备份当前的安装源目录
- \cp -rp /etc/yum.repos.d/ /etc/yum.repos.d_back
复制代码
下载阿里云的安装源
- wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
复制代码
②操作完成后,执行清理之前安装源的缓存命令,然后重新生成新的阿里云的安装源缓存
- yum clean all
- yum makecache
复制代码
2、Ubuntu系列安装源太老,请参考下面的清华源
3、Debian系列安装源太老,请参考下面的清华源
1、CentOS7
①、先备份当前的安装源目录
- \cp -rp /etc/yum.repos.d/ /etc/yum.repos.d_back
复制代码
②、注释mirrorlist
- sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
复制代码
③、将baseurl的地址指向清华源
- sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' /etc/yum.repos.d/CentOS-*.repo
复制代码
替换后,执行下面命令进行生成软件包的缓存
- yum clean all
- yum makecache
复制代码
仅仅提供LTS系列和Ubuntu21的安装源
2、Ubuntu18.04LTS
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
复制代码
②、添加清华源
- cat >/etc/apt/sources.list <<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
- # 预发布软件源,不建议启用
- # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
- EOF
复制代码
③、更新软件包缓存
- apt-get update -y
复制代码
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates
复制代码
2.1、Ubuntu20.04 LTS
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
复制代码
②、添加清华源
- cat > /etc/apt/sources.list<<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- # 预发布软件源,不建议启用
- # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- EOF
复制代码
③、更新软件包缓存
- apt-get update -y
复制代码
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates
复制代码
2.3、Ubuntu21.04
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
复制代码
②、添加清华源
- cat >/etc/apt/sources.list <<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse
- # 预发布软件源,不建议启用
- # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
- EOF
复制代码
③、更新软件包缓存
- apt-get update -y
复制代码
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates
复制代码
debian系列暂时只考虑 bullseye发行版(其他的版本请参考清华源:https://mirrors.tuna.tsinghua.edu.cn/help/debian/)
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
复制代码
②、添加清华源
- cat >/etc/apt/sources.list <<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
- deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
- deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
- deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
- EOF
复制代码
③、更新软件包缓存
- apt-get update -y
复制代码
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates