yum - epel源

背景

EPEL (Extra Packages for Enterprise Linux) 是Fedora小组维护的一个软件仓库项目,提供了官方源不支持的或者官方更新缓慢的包,很多开源软件需要用epel源进行安装,do it.

安装

1.查看已有源,sudo yum repolist

Loading mirror speeds from cached hostfile
 * epel: mirror.sjc02.svwh.net

2.卸载。如果已有epel 源但不可用并且问题不好定位,则执行yum -y remove epel-release卸载旧版

3.安装epel源

; centos7就选`latest-7`,同理6选latest-6
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

4.安装rpm

sudo yum install epel-release-latest-7.noarch.rpm

5.检查版本:

rpm -q epel-release

其他

  1. yum repo的路径为/etc/yum.repos.d
  2. epel.repo的文件内容如下,如果需要关闭某个源,则将配置文件中的enabled置为0
 [epel]
 name=Extra Packages for Enterprise Linux 7 - $basearch
 #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
 metalink=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://download.fedoraproject.org/pub/epel/7/$basearch/debug
 metalink=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://download.fedoraproject.org/pub/epel/7/SRPMS
 metalink=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
### 如何正确使用 `yum` 安装 EPEL 为了成功安装并配置 EPEL ,可以按照以下方式操作: #### 1. 确保基础环境正常 在执行任何命令之前,请确认系统的 YUM 已正确配置。如果遇到类似“Could not retrieve mirrorlist”的错误,则可能是因为网络连接问题或者镜像站点不可达[^5]。 可以通过更换国内的 CentOS 镜像来解决问题。例如阿里云提供了稳定的 CentOS 镜像服务。以下是具体的操作步骤: ```bash mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum clean all yum makecache ``` 完成上述更改后,再次尝试更新或安装软件包以验证新是否生效[^4]。 #### 2. 使用官方推荐的方式安装 EPEL 对于 CentOS 7 用户来说,可以直接通过如下命令安装 EPEL 软件仓库支持: ```bash yum install epel-release -y ``` 这条指令会自动下载并设置好所有的必要文件[^1]。然而,在某些情况下可能会因为网络原因或者其他因素而失败,比如提示 “One of the configured repositories failed (unKnown)” 的情况就属于此类问题[^2]。 #### 3. 手动添加 EPEL 作为替代方案 当标准途径受阻时,还可以考虑手动引入 RPM 文件形式的 EPEL 发布版。下面给出了一种可行的方法: ```bash rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm ``` 此方法绕过了潜在的问题节点,并直接加载最新的稳定版本至本地系统中。 另外需要注意的是,有时即使完成了以上所有步骤仍可能出现诸如“There are no enabled repos”这样的警告消息;这通常意味着当前活动状态下的存储库列表为空。此时可运行 `yum repolist` 查看实际状况,并依据反馈采取进一步措施调整可用资链接地址等内容[^3]。 最后提醒一点,务必保持良好的互联网访问条件以及合理规划防火墙策略以免干扰正常的在线交互过程! ```python import os if __name__ == "__main__": command = "yum install epel-release -y" result = os.system(command) if result != 0: print("Failed to execute:", command) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值