首页 > 代码库 > Centos 7 添加epel源

Centos 7 添加epel源

由于部分包仅存在于epel源中,所以我们在centos中添加;


以下提供了2种方法,1手动,2自动


1、手动方法

vi/etc/yum.repos.d/epel.repo

添加以下代码

[epel]
name=ExtraPackages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
 
[epel-debuginfo]
name=ExtraPackages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/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=ExtraPackages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/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

更新yum缓存

yum makecache

查看yum源

yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.edu.cn
repo id                                     repo name                                                                 status
base/7/x86_64                               CentOS-7 - Base                                                            9,007
*epel/x86_64                                Extra Packages for Enterprise Linux 7 - x86_64                            10,547
extras/7/x86_64                             CentOS-7 - Extras                                                            377
updates/7/x86_64                            CentOS-7 - Updates                                                         2,311
repolist: 22,242


2、自动方法

安装epel源

yum install -y epel-release

查看yum源

yum repolist
Loaded plugins: fastestmirror
epel/x86_64/metalink                                                                                 | 5.4 kB  00:00:00     
epel                                                                                                 | 4.3 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                                          | 170 kB  00:00:00     
(2/3): epel/x86_64/updateinfo                                                                        | 622 kB  00:00:01     
(3/3): epel/x86_64/primary_db                                                                        | 4.2 MB  00:00:06     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.cn99.com
 * updates: centos.ustc.edu.cn
repo id                                     repo name                                                                 status
base/7/x86_64                               CentOS-7 - Base                                                            9,007
epel/x86_64                                 Extra Packages for Enterprise Linux 7 - x86_64                            10,548
extras/7/x86_64                             CentOS-7 - Extras                                                            377
updates/7/x86_64                            CentOS-7 - Updates                                                         2,311
repolist: 22,243


这两种方法都可以,可能第一种采用了国外源对部分用户不适用.

在我这边,这两种区别不大.

本文出自 “尔与同愁” 博客,请务必保留此出处http://mannerwang.blog.51cto.com/12009183/1852806

Centos 7 添加epel源