美文网首页
CentOS 修改 yum 源

CentOS 修改 yum 源

作者: ahcj_11 | 来源:发表于2017-08-15 22:20 被阅读77次

    1.安装 CentOS-Base 国内源

    备份旧的配置文件

    mv CentOS-Base.repo CentOS-Base.repo.bak
    

    使用 aliyun

    # CentOS 7 / RHEL 7
    wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    
    # CentOS 6 / RHEL 6
    wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
    

    使用 163

    #CentOS 7 / RHEL 7
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
    
    #CentOS 6 / RHEL 6
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
    

    2. 安装 EPEL 源:

    企业版 Linux 附加软件包(以下简称 EPEL)是一个由特别兴趣小组创建、维护并管理的,针对 红帽企业版 Linux(RHEL)及其衍生发行版(比如 CentOS、Scientific Linux、Oracle Enterprise Linux)的一个高质量附加软件包项目。
    EPEL 的软件包通常不会与企业版 Linux 官方源中的软件包发生冲突,或者互相替换文件。EPEL 项目与 Fedora
    基本一致,包含完整的构建系统、升级管理器、镜像管理器等等。

    上海交大

    # CentOS 7 / RHEL 7
    yum install http://ftp.sjtu.edu.cn/fedora/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
    
    # CentOS 6 / RHEL 6
    yum install http://ftp.sjtu.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
    
    

    Aliyun

    # CentOS 7 / RHEL 7
    yum install  http://mirrors.aliyun.com/repo/epel-7.repo
    
    # CentOS 6 / RHEL 6
    yum install  http://mirrors.aliyun.com/repo/epel-6.repo
    

    浙大源

    # CentOS 7 / RHEL 7
    yum install  http://mirrors.zju.edu.cn/epel/epel-release-latest-7.noarch.rpm
    
    # CentOS 6 / RHEL 6
    yum install  http://mirrors.zju.edu.cn/epel/epel-release-latest-6.noarch.rpm
    

    东软源

    # CentOS 7 / RHEL 7
    yum install  http://mirrors.neusoft.edu.cn/epel/epel-release-latest-7.noarch.rpm
    # CentOS 6 / RHEL 6
    yum install  http://mirrors.neusoft.edu.cn/epel/epel-release-latest-6.noarch.rpm
    

    Sohu

    # CentOS 7 / RHEL 7
    yum install  http://mirrors.sohu.com/fedora-epel/epel-release-latest-7.noarch.rpm
    
    # CentOS 6 / RHEL 6
    yum install  http://mirrors.sohu.com/fedora-epel/epel-release-latest-6.noarch.rpm
    

    配置EPEL源

    vi /etc/yum.repos.d/epel.repo
    
    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    baseurl=http://ftp.sjtu.edu.cn/fedora/epel/7/$basearch
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
     
    [epel-debuginfo]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
    baseurl=http://ftp.sjtu.edu.cn/fedora/epel/7/$basearch/debug
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
     
    [epel-source]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Source
    baseurl=http://ftp.sjtu.edu.cn/fedora/epel/7/SRPMS
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    
    vi /etc/yum.repos.d/epel-testing.repo
    
    [epel-testing]
    name=Extra Packages for Enterprise Linux 7 - Testing - $basearch
    baseurl=http://ftp.sjtu.edu.cn/fedora/epel/testing/7/$basearch
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-epel7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
     
    [epel-testing-debuginfo]
    name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Debug
    baseurl=http://ftp.sjtu.edu.cn/fedora/epel/testing/7/$basearch/debug
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
     
    [epel-testing-source]
    name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Source
    baseurl=http://ftp.sjtu.edu.cn/fedora/epel/testing/7/SRPMS
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    

    这是已经替换好上海交大源的文件,如果想使用中科大的,请用http://mirrors.ustc.edu.cn/来替换http://ftp.sjtu.edu.cn/fedora/就可。其它以此类推。

    3. 添加 remi 源

    Remi repository 是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护。有个这个源之后,使用
    YUM 安装或更新 PHP、MySQL、phpMyAdmin 等服务器相关程序的时候就非常方便了。他会自动安装 epel 作为依赖。

    # CentOS 7 / RHEL 7
    yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    
    # CentOS 6 / RHEL 6
    yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
    

    yum安装MySQL 5.5看看:

    yum --enablerepo=remi install mysql mysql-server
    

    如果是升级MySQL,请用:

    yum --enablerepo=remi update mysql mysql-server
    

    4. 检查源是否已添加

    yum repolist
    

    5. 清理 并 重新生成缓存

    yum clean all && yum makecache
    

    相关文章

      网友评论

          本文标题:CentOS 修改 yum 源

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