How to Set Up Local Yum Repositories on CentOS 7

April 29, 2019


In Linux, a repository is a central database of software. Linux distributions have a central repository for system and commonly-used software.

Often administrators may have a need for a specialized software package, or to manage network bandwidth. For these reasons, they need to set up a new custom local repository.

Yum is a local repository for RPM package files. These packages compress available software for Linux distributions. With the repository, you can download, install and hold packages on a local disk or remotely.

This tutorial walks you through setting up a local Yum repository on CentOS 7.

how to install yum repository on centos7


  • Access to a user account with root or sudo privileges
  • Access to a terminal window/command-line (Menu > Applications > Utilities > Terminal)
  • The YUM (Yellowdog Updater Modified) package manager, installed by default

Set Up and Configure Yum Repositories on CentOS

Step 1: Configure Network Access

Firstly, hosting a yum repository requires you to configure the system for network access.

Yum typically delivers files over either FTP or HTTP. However, you cannot configure for both, so take a moment to decide which method you would like to use.

If you already have the system configured as a web server with Apache or an FTP server with vsftpd, skip to Step 2.

To use HTTP, install the Apache web services package with the command:

sudo yum install httpd

If you are using FTP instead, install the vsftpd software package with:

sudo yum install vsftpd

This is an example of an output with the latest version already installed:


Note: Instead of Apache, you can also use Nginx as a web server. Before doing so, make sure you open the correct ports on your firewall (Port 80 for HTTP, Port 21 for FTP).

Step 2: Create Yum Local Repository

One helpful tool is the createrepo software package. This software bundles several .rpm files together into a repomd repository. Install the software by entering the following:

sudo yum install createrepo

Next, install yum-utils to give your system a better toolbox for managing repositories. Install yum-utils by entering the following:

sudo yum install yum-utils

This is an example of a possible output:


Step 3: Create a Directory to Store the Repositories

Then, create a directory for an HTTP repository using:

sudo mkdir –p /var/www/html/repos/{base,centosplus,extras,updates}

Alternaticreate an FTP directory by typing the following:

sudo mkdir –p /var/ftp/repos

Step 4: Synchronize HTTP Repositories

Download a local copy of the official CentOS repositories to your server. This allows systems on the same network to install updates more efficiently.

To download the repositories, use the commands:

sudo reposync -g -l -d -m --repoid=base --newest-only --download-metadata --download_path=/var/www/html/repos/
sudo reposync -g -l -d -m --repoid=centosplus --newest-only --download-metadata --download_path=/var/www/html/repos/
sudo reposync -g -l -d -m --repoid=extras --newest-only --download-metadata --download_path=/var/www/html/repos/
sudo reposync -g -l -d -m --repoid=updates --newest-only --download-metadata --download_path=/var/www/html/repos/

The system should reach out and download copies of the official repositories.

In the previous commands, the options are as follows:

  • –g – lets you remove or uninstall packages on CentOS that fail a GPG check
  • –l – yum plugin support
  • –d – lets you delete local packages that no longer exist in the repository
  • –m – lets you download comps.xml files, useful for bundling groups of packages by function
  • ––repoid – specify repository ID
  • ––newest-only – only download the latest package version, helps manage the size of the repository
  • ––download-metadata – download non-default metadata
  • ––download-path – specifies the location to save the packages

If you’re using FTP, substitute your FTP directory in the commands above. You can also use your installation CD as a source for repositories.

First, mount the cd, then copy the files into your FTP directory with the following:

cp /media/packages/* /var/ftp/repos

Step 5: Create the New Repository

We’ll use the createrepo utility to create a repository.

To create the repository for HTTP use the command:

sudo createrepo /var/www/html

The terminal will display the following information:


Similarly, create a repository for FTP, enter the following:

sudo createrepo /var/ftp

Step 6: Setup Local Yum Repository on Client System

Now set up a local Yum Repository on a clients machine.

1. First, switch to the client system and login as a user with root or sudo privileges.

2. Next, you’ll need to prevent yum from downloading from the wrong location. To do this, move the default yum repository files with the following command:

mv /etc/yum.repos.d/*.repo /tmp/

This command stores the files in the /tmp/ directory. You can substitute any other location you’d like.

3. Create and edit a new config file:

sudo nano /etc/yum.repos.d/remote.repo

The system should open a new file in a text editor.

4. In the new file, enter the command (replacing the IP address with the IP address of your server):


name=RHEL Apache




5. Finally, save the file and exit.

If you’re configuring for FTP, use the following instead (replacing the IP address with the IP address of your server):






Step 7: Test the Configuration

While still on the client system, run a command to install a package with the yum package manager:

sudo yum install httpd

The system should accordingly reach out to your server and install the software.


After following these steps, you now know how to set up a local YUM repository on CentOS 7.

In addition to downloading the default repositories (or copying them from the CD), you can also copy any other software packages into your storage folder. This provides a simple and central location that users can access and install software.

Was this article helpful?
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to List Installed Packages on CentOS with Yum or RPM
April 29, 2019

Managing a CentOS operating system often means knowing the software packages that are installed. This list ...
Read more
How to Install Pip on CentOS 7
January 17, 2019

Pip Installs Packages (Pip) is a package management system that simplifies the process of installing and ...
Read more
How to use apt Package Manager on Ubuntu Linux
January 7, 2019

In Linux, special tools were developed for managing applications. Application software for Linux typically ...
Read more
How to Use SSH to Connect to a Remote Server in Linux or Windows
November 23, 2023

In this tutorial, Find out How To Use SSH to Connect to a Remote Server in Linux or Windows. Get started with ...
Read more