centos7 yum添加源或换源

yum添加源或换源

一般来说yum源是我们需要下载的软件的远程仓库地址(当然也可以配置本地源),centos系统带有几个官方源,默认启用的仅有base,updates和extras三个。有时我们需要的软件在官方源中没有,这时我们就需要添加第三方源或换默认源。

yum源存放位置在: /etc/yum.repos.d/

源管理命令

列出所有启用的源

yum repolist    //等同于yum repolist enabled

列出所有禁用的源

yum repolist disabled

第三方源

添加第三方源不会替换默认源,只是多了源的来源

EPEL

EPEL是Extra Packages for Enterprise Linux的缩写,其为EL6或EL7提供重建的Fedora组件,并且不会替换base中的包。EPEL算得上是最著名的第三方软件源,几乎各个云服务器厂商提供的CentOS 系统均会自带该源并默认启用。其收录了web中常用的Nginx软件包

官网:Extra Packages for Enterprise Linux (EPEL) :: Fedora Docs

安装命令

yum install -y epel-release

SCL

SCL是Software Collections的缩写,由CentOS 特别兴趣小组所维护。其收录了许多程序的新版本,例如gcc, PHP, git, python等。安装的软件可与旧版共存,包名多以rh-为前缀。

官网:Software Collections — Software Collections

安装命令

yum install centos-release-scl

ELRepo

ELRepo是The Community Enterprise Linux Repository的缩写,旨在提供驱动程序来增强系统的硬件支持(包括:显示、文件系统、硬件监控、网络、音效、网络摄像镜驱动程序)。也提供较新版的内核,例如支持BBR算法的4.9+内核。

官网:ELRepo | HomePage

安装命令

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

安装完成后在/etc/yum.repos.d目录下出现elrepo.repo文件,可编辑文件中的enable的值启用具体仓库,也可在运行时用--enablerepo="xxx"指定使用的软件库。

IUS

IUS的官网是https://ius.io/,旨在为RHEL和CentOS提供高质量、最新版的软件,如PHP, Python, MySQL等。

安装命令

rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm

RPMfusion

RPMfusion提供Fedora Project或 Red Hat不愿发行的软件,包含“免费(开源软件)”和“非免费(源代码可公开获取但不开源且限非商业用途)”两种类型的仓库。

官网::RPM Fusion - RPM Fusion

安装命令

# 免费库
yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
# 非免费库
yum localinstall --nogpgcheck https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm

Remi

Remi维护大量组件,包括最新版的PHP, GLPI等。Remi的safe仓库不会替代系统的基本组件,但remi-phpxx.repo中的软件包会替代系统默认的php。需要注意的是Remi可能会与IUS的软件包冲突,因为双方都提供最新版的PHP。

官网:Remi's RPM repository

安装命令

yum install -y remi-release

换默认源

网易163源

备份默认源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载对应的版本源(这里以centos7为例)
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

修改名称

mv CentOS7-Base-163.repo CentOS-Base.repo

更新缓存

yum makecache

中科大源

替换默认仓库

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-Base.repo

更新缓存

yum makecache

阿里云源

备份默认源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载对应的版本源(这里以centos7为例)

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

更新缓存

yum makecache

清华大学源

替换默认仓库

# 对于 CentOS 7
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos|g' \
    -i.bak \
    /etc/yum.repos.d/CentOS-*.repo

# 对于 CentOS 8
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos|g' \
    -i.bak \
    /etc/yum.repos.d/CentOS-*.repo

更新缓存

yum makecache

相关推荐

  1. centos 8

    2024-01-10 07:06:03       7 阅读
  2. centos7更新yum安装docker-ce使用阿里

    2024-01-10 07:06:03       33 阅读
  3. linux CentOS7配置docker的yum并安装

    2024-01-10 07:06:03       14 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-10 07:06:03       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-10 07:06:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-10 07:06:03       20 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-10 07:06:03       20 阅读

热门阅读

  1. Android studio TabHost应用设计

    2024-01-10 07:06:03       37 阅读
  2. SQL Server定时调用指定WebApi接口

    2024-01-10 07:06:03       38 阅读
  3. VSCode 安装 Copilot 详细过程和实例

    2024-01-10 07:06:03       39 阅读
  4. 关于springboot项目集成kafka的常见错误

    2024-01-10 07:06:03       35 阅读
  5. kafka KRaft 集群搭建

    2024-01-10 07:06:03       38 阅读
  6. Kafka的@KafkaListener注解参数详解

    2024-01-10 07:06:03       33 阅读
  7. vue解析前端对象为Array数组并且遍历

    2024-01-10 07:06:03       34 阅读
  8. AWS Directory Service 开启ldaps

    2024-01-10 07:06:03       33 阅读