许都

31 0

CentOS 7 系统使用 yum 包管理器,yum 的软件源配置文件存放于 /etc/yum.repos.d/ 目录下。备份并删除目录下所有的 CentOS-*.repo条目,创建 centos.repo 文件:

Shell
  1. #先进入目录
  2. cd /etc/yum.repos.d/
  3. #执行编辑新建文件,按i进入编辑模式复制粘贴下面的内容按ESC再按:最后键入wq保存退出。下面添加epel源相同操作。
  4. vi centos.repo
复制 文本 高亮
Shell
  1. [base]
  2. name=CentOS-$releasever - Base
  3. baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
  4. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  5. gpgcheck=1
  6. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  7. #released updates
  8. [updates]
  9. name=CentOS-$releasever - Updates
  10. baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
  11. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  12. gpgcheck=1
  13. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  14. #additional packages that may be useful
  15. [extras]
  16. name=CentOS-$releasever - Extras
  17.  
  18. baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
  19. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  20. gpgcheck=1
  21. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  22. #additional packages that extend functionality of existing packages
  23. [centosplus]
  24. name=CentOS-$releasever - Plus
  25. baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
  26. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  27. gpgcheck=1
  28. enabled=0
  29. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
复制 文本 高亮
Shell
  1. #执行命令更新。
  2. yum update
  3. #执行这会自动设置新的软件源,也会安装 RPM-GPG-KEY-EPEL-7。
  4. yum install epel-release
复制 文本 高亮

备份并移除所有的 epel*.repo 条目,创建 epel.repo文件:

Shell
  1. [epel]
  2. name=Extra Packages for Enterprise Linux 7 - $basearch
  3. baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/$basearch
  4. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
  5. failovermethod=priority
  6. enabled=1
  7. gpgcheck=1
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  9. [epel-debuginfo]
  10. name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
  11. baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
  12. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
  13. failovermethod=priority
  14. enabled=0
  15. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  16. gpgcheck=1
  17. [epel-source]
  18. name=Extra Packages for Enterprise Linux 7 - $basearch - Source
  19. baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/SRPMS
  20. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
  21. failovermethod=priority
  22. enabled=0
  23. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  24. gpgcheck=1
复制 文本 高亮
Shell
  1. yum update
复制 文本 高亮

至此,安装yum源和epel 源就完成了。

发表评论 取消回复
表情 图片 链接 代码