美文网首页小白运维之路linux
linux各大发行版修改软件源为国内加速镜像

linux各大发行版修改软件源为国内加速镜像

作者: 行书以鉴 | 来源:发表于2017-09-03 00:26 被阅读409次

    伟大的tianchao防火墙吖~ 早就打算写这么一篇文章了,专注解决各类Linux系统的的软件源的配置问题,将软件源配置为国内的镜像。

    软件源的修改相当,各类系统只需要修改对应的包管理工具的源配置文件就好了。

    国内镜像源

    教育网镜像

    还有蛮多的镜像源,这里就不缀述.


    各系统软件源修改方法

    下面各类系统以修改为阿里云的镜像源为示例进行说明

    CentOS
    # 备份原文件
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
    
    # 下载新的CentOS-Base.repo 到/etc/yum.repos.d/
    
    #CentOS 5
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
    
    #CentOS 6
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
    
    #CentOS 7
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    
    # 生成缓存
    yum makecache
    
    Debian
    系统代号 版本
    squeeze 6.x
    wheezy 7.x
    jessie 8.x

    debian jessie是稳定版
    下面的修改以 jessie(8.x)为例:

    # 备份原文件
    mv /etc/apt/sources.list /etc/apt/sources.list.bak
    
    # 修改为阿里云的镜像源
    #这个是专门为阿里云ECS的debian jessie系列所做的换源操作
    #如有其他需要 请自行更改
    rm -rf /etc/apt/sources.list.d/sources-aliyun*
    
    cat > /etc/apt/sources.list.d/sources-aliyun-0.list << END
    deb http://mirrors.cloud.aliyuncs.com/debian/ jessie main contrib non-free
    deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie main contrib non-free
    deb http://mirrors.cloud.aliyuncs.com/debian/ jessie-proposed-updates main non-free contrib
    deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie-proposed-updates main non-free contrib
    deb http://mirrors.cloud.aliyuncs.com/debian/ jessie-updates main contrib non-free
    deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie-updates main contrib non-free
    END
    
    
    # 更新源列表信息
    apt-get update
    
    Ubuntu
    系统代号 版本
    precise 12.04
    trusty 14.04
    vivid 15.04
    xenial 16.04
    zesty 17.04

    下面的修改以 trusty(14.04)为例:

    # 备份原文件
    mv /etc/apt/sources.list /etc/apt/sources.list.bak
    
    # 修改为阿里云的镜像源
    cat > /etc/apt/sources.list << END
    deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    END
    
    # 更新源列表信息
    apt-get update
    

    如果失败,可以看[这篇文章](云服务器 ECS Ubuntu apt-get 在线安装软件和常见问题处理介绍)

    Alpine

    目前Docker镜像越来越倾向于使用Alpine系统作为基础的系统镜像
    下面的修改以 Alpine 3.4 为例:

    # 备份原始文件
    cp /etc/apk/repositories /etc/apk/repositories.bak
    
    # 修改为国内镜像源
    echo "http://mirrors.aliyun.com/alpine/v3.4/main/" > /etc/apk/repositories
    

    转https://t.goodrain.com/t/topic/236/1

    相关文章

      网友评论

        本文标题:linux各大发行版修改软件源为国内加速镜像

        本文链接:https://www.haomeiwen.com/subject/ktldjxtx.html