In most scenarios, when you build out a new system, you want to keep the installation footprint as small as possible. As a result, not all repositories and packages are typically installed at that time. Fortunately, repositories can be enabled and disabled through yum at any time, and there are many different sources you can choose from.

In this example, we'll look specifically at Fedora, but the process is similar across other distributions utilizing yum.

It is always recommended you use a known repository, such as Extra Packages for Enterprise Linux (EPEL), which is hosted at fedoraproject.org. Or, you might need a specific version of MySQL, which is hosted at mysql.com. There are also circumstances where you might need to add a lesser-known repository, such as remirepo.net for versions of PHP, or even host your own repository.

Once you determine which repository you need, there are several different ways to install and enable it.

Install a repository .rpm

The first is to install an .rpm with the repository information. The following command installs the EPEL repository for CentOS 8:

# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Set up only a section of a repository

In the case of needing a specific repository, as in the case of PHP 7.2, you first need to install the repo and then disable and enable repositories using yum-config-manager as follows:

$ sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ sudo yum-config-manager --disable remi-php54
$ sudo yum-config-manager --enable remi-php72

Manually set up a repository

The last method of configuring a yum repository manually, where we create a .repo file within /etc/yum.repo.d using a text editor. In this example, we will create the repository file for MySQL 5.7:

$ nano /etc/yum.repo.d/mysql57-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Now, let’s discuss the lines we configured. The first three lines contain the minimum information you need when creating a .repo file. The first line is the unique identifier for the section and is enclosed in []:

[mysql57-community]

Note: You can have more than section (repository) in a .repo file.

The second line in our file is the name we choose to describe the repository:

name=MySQL 5.7 Community Server

The third line is the location (baseurl) of the repository. In this case, we are using HTTP to access it:

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/

As we mentioned, the first three lines are mandatory to configure a repository. We have also configured three more options. In the first additional option, we configured the toggle enabled, where 0 is disabled and 1 is enabled:

enabled=1

In the last two lines, we configured our information related to GPG. The first of these lines is the toggle to check for GPG and the second is the location of the key you are checking against:

gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

To see a complete list of repository options, see the man page as follows:

$ man yum.conf

Now that you have your new repository configured using one of these methods, you should verify that it is configured properly using the yum-config-manager command from earlier to enable and disable PHP sections:

# yum-config-manager mysql57-community

This command returns the complete information for the repository:

[root@centos3 yum.repos.d]# yum-config-manager mysql57-community
Loaded plugins: fastestmirror
================================================================================================= repo: mysql57-community ==================================================================================================
[mysql57-community]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7/mysql57-community
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage = 
enabled = True
enablegroups = True
exclude = 
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgcadir
gpgcakey = 
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
hdrdir = /var/cache/yum/x86_64/7/mysql57-community/headers
http_caching = all
includepkgs = 
ip_resolve = 
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid = 
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink = 
minrate = 0
mirrorlist = 
mirrorlist_expire = 86400
name = MySQL 5.7 Community Server
old_base_cache_dir = 
password = 
persistdir = /var/lib/yum/repos/x86_64/7/mysql57-community
pkgdir = /var/cache/yum/x86_64/7/mysql57-community/packages
proxy = False
proxy_dict = 
proxy_password = 
proxy_username = 
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = True
throttle = 0
timeout = 30.0
ui_id = mysql57-community/x86_64
ui_repoid_vars = releasever,
   basearch
username =

With your repository installed, you are ready to use yum to install the packages located there!

[ Want to try out Red Hat Enterprise Linux? Download it now for free. ]


저자 소개

Amy Marrich is a Principal Technical Marketing Manager at Red Hat. She previously worked at a small open source e-assessment company in Luxembourg, where she was the Open Source Community and Global Training Manager.  Previously, she was the OpenStack Instructor at Linux Academy and a Linux System Engineer on the Platform Engineering Cloud Operations team at Rackspace. She currently serves on the OpenStack Board, is an active member of the Openstack Ansible project, and was previously the chair of the OpenStack User Committee. Amy spends her free time competing in performance events (agility, FASt Cat, and dock diving) with her Dalmatians and competing in dressage with her Connemara pony.

UI_Icon-Red_Hat-Close-A-Black-RGB

채널별 검색

automation icon

오토메이션

기술, 팀, 인프라를 위한 IT 자동화 최신 동향

AI icon

인공지능

고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트

open hybrid cloud icon

오픈 하이브리드 클라우드

하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요

security icon

보안

환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보

edge icon

엣지 컴퓨팅

엣지에서의 운영을 단순화하는 플랫폼 업데이트

Infrastructure icon

인프라

세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보

application development icon

애플리케이션

복잡한 애플리케이션에 대한 솔루션 더 보기

Virtualization icon

가상화

온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래