Centos 7 添加epel源

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


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


1、手动方法

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

添加以下代码

[epel]
name=ExtraPackagesforEnterpriseLinux7-$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=ExtraPackagesforEnterpriseLinux7-$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=ExtraPackagesforEnterpriseLinux7-$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缓存

yummakecache

查看yum源

yumrepolist
Loadedplugins:fastestmirror
Loadingmirrorspeedsfromcachedhostfile
*base:mirrors.zju.edu.cn
*epel:mirror01.idc.hinet.net
*extras:mirrors.zju.edu.cn
*updates:mirrors.zju.edu.cn
repoidreponamestatus
base/7/x86_64CentOS-7-Base9,007
*epel/x86_64ExtraPackagesforEnterpriseLinux7-x86_6410,547
extras/7/x86_64CentOS-7-Extras377
updates/7/x86_64CentOS-7-Updates2,311
repolist:22,242


2、自动方法

安装epel源

yuminstall-yepel-release

查看yum源

yumrepolist
Loadedplugins:fastestmirror
epel/x86_64/metalink|5.4kB00:00:00
epel|4.3kB00:00:00
(1/3):epel/x86_64/group_gz|170kB00:00:00
(2/3):epel/x86_64/updateinfo|622kB00:00:01
(3/3):epel/x86_64/primary_db|4.2MB00:00:06
Loadingmirrorspeedsfromcachedhostfile
*base:mirrors.aliyun.com
*epel:mirror01.idc.hinet.net
*extras:mirrors.cn99.com
*updates:centos.ustc.edu.cn
repoidreponamestatus
base/7/x86_64CentOS-7-Base9,007
epel/x86_64ExtraPackagesforEnterpriseLinux7-x86_6410,548
extras/7/x86_64CentOS-7-Extras377
updates/7/x86_64CentOS-7-Updates2,243


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

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

相关文章

linux下开机自启: 在/etc/init.d目录下新建文件elasticsear...
1、因为在centos7中/etc/rc.d/rc.local的权限被降低了,所以...
最简单的查看方法可以使用ls -ll、ls-lh命令进行查看,当使用...
ASP.NET Core应用程序发布linux在shell中运行是正常的。可一...
设置时区(CentOS 7) 先执行命令timedatectl status|grep &...
vim /etc/sysconfig/network-scripts/ifcfg-eth0 B...