Set Up and Configure a Local Yum Repository on CentOS 7 in 6 Easy Steps

Try this guide with our instant dedicated server for as low as 40 Euros

local YUM repository

In Linux environments, a repository acts as a centralized storage location for software packages. Most Linux distributions maintain a primary repository for system software and other widely used applications.

However, administrators sometimes require specialized software that isn’t available in the distribution’s main repositories. In other cases, they might need to manage network bandwidth more efficiently. In such cases, setting up a custom local repository becomes necessary.

Yum is a management tool for repositories containing RPM package files, which are compressed archives of software compatible with many Linux distributions. Through a Yum repository, you can download, install, and manage software packages, either from a local storage medium or over a network.

This guide will walk you through setting up a local Yum repository on a CentOS 7 system.

Table Of Contents

  1. Setting Up and Configuring Yum Repositories on CentOS
    1. The Prerequisites for Setting Up a Local Yum Repository
    2. Step #1: Configure Network Access
    3. Step #2: Create Your Local Yum Repository
    4. Step #3: Create a Directory to Store the Repositories
    5. Step #4: Synchronize HTTP Repositories
    6. Step #5: Create the New Repository
    7. Step #6: Set Up a Local Yum Repository on a Client System
  2. Conclusion
  3. FAQs

Setting Up and Configuring Yum Repositories on CentOS

Before we go into the details of the steps,  let’s take a look at the prerequisites.

The Prerequisites for Setting Up a Local Yum Repository 

Before you start, make sure you have the following prerequisites:

Root or Sudo Privileges: You must have access to a user account with root or sudo privileges to modify system configurations and install software.

Terminal Access: You should be able to access a terminal window or command-line interface. On most systems, you can find this under Menu > Applications > Utilities > Terminal.

YUM Package Manager: Your system should have the YUM package manager installed, which is standard with CentOS 7. YUM allows you to manage software packages efficiently.

Step #1: Configure Network Access

To host a Yum repository, your system needs proper network configuration since Yum repositories typically distribute files over FTP or HTTP. You must choose one of these protocols based on your network setup or preferences.

If your system is already configured as a web server using Apache, or as an FTP server using vsftpd, you can proceed directly to the next step.

If your system does not already have Apache installed, you will need to install it to serve the Yum repository via HTTP.

Start by running the following command to install Apache:

# sudo yum install httpd

sudo yum install httpd

If you prefer FTP over HTTP, you can install the FTP server, vsftpd, by running this command:

#sudo yum install vsftpd

sudo yum install vsftpd

This command sets up vsftpd on your CentOS system, allowing you to serve files via FTP.

Step #2: Create Your Local Yum Repository

Next, you need to install createrepo to set up your local Yum repository. This software package aggregates multiple .rpm files into a single repository, making them easier to manage. 

Run the following command to Install createrepo on your system:

# sudo yum install createrepo

sudo yum install createrepo

After installing createrepo, it is a good idea to also install yum-utils. This package provides additional tools that enhance the management of repositories and packages. 

# sudo yum install yum-utils

sudo yum install yum-utils

With these tools, you can better organize and maintain your local Yum repository, streamlining package management on your network.

Step #3: Create a Directory to Store the Repositories

Next, set up a directory to hold the HTTP repository files. Execute the following mkdir command to create the necessary subdirectories:

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

Alternatively, if you prefer to set up an FTP repository, create the corresponding directory with this command:

#sudo mkdir -p /var/ftp/repos

Step #4: Synchronize HTTP Repositories

You now need to obtain a local copy of the official CentOS repositories on your server to allow systems on the same network to install updates more efficiently. This process involves the following steps:

Download the Repositories

To synchronize the repositories, execute the following 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/

synchronization of repositories

These commands initiate the download of the official CentOS repositories to your specified directory.

Explanation of Command Options:

  • -g: Remove or uninstall packages that fail a GPG signature check.
  • -l: Enable YUM plugin support.
  • -d: Delete local packages no longer present in the repository.
  • -m: Download comps.xml files, which are useful for grouping packages by function.
  • –repoid: Specify the repository ID.
  • –newest-only: Download only the latest version of packages to manage repository size efficiently.
  • –download-metadata: Download additional, non-default metadata.
  • –download-path: Set the directory where the packages will be saved.

Alternative: Setting Up FTP

If you prefer using FTP for repository storage, substitute the HTTP directory paths in the commands above with your FTP directory path.

Additionally, if you have an installation CD, you can use it as a repository source by first mounting the CD and then copying the packages. For this, we recommend using the cp command:

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

This method allows you to populate your FTP repository with data directly from your CentOS installation media.

Step #5: Create the New Repository

In this step, you’ll use the createrepo utility to establish a new repository. This utility helps organize the RPM packages (in the directory you created in the previous step) into a repository that the YUM/DNF package manager can use.

Create a Repository for HTTP

To create a repository accessible via HTTP, use the following command:

# sudo createrepo /var/www/html

Create the New Repository

Upon execution, the terminal will display information confirming the creation of the repository.

Create a Repository for FTP

For setting up a repository accessible via FTP, run the command:

#sudo createrepo /var/ftp

Create a Repository for FTP

This will initialize the repository in the FTP directory, organizing the RPM packages into a usable repository format.

Step #6: Set Up a Local Yum Repository on a Client System

  1. Log in to the Client System
    Ensure you log in as a user with root or sudo privileges.
  2. Disable Default Repositories
    Move the default repository files to avoid conflicts:

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

  1. Create a New Repository Configuration
    Open a new config file with a text editor:

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

  1. Add Repository Details

For an HTTP server, add the following lines (replace with your server’s IP):


name=RHEL Apache




For FTP, use this instead (again, replace with your server’s IP):






  1. Save and Close the File
    Save your changes (Ctrl+O, Enter) and exit (Ctrl+X).
  2. Test the Setup
    Clear Yum cache and test your repository:

# sudo yum clean all

# sudo yum repolist

This sets up the client to use packages from your local server, improving installation speeds and control over updates.

Test by installing a package:

Try installing a package to confirm that the repository settings are correct. For instance, we suggest the following command to install Apache:

# sudo yum install httpd


Setting up local Yum repositories on CentOS 7 is essential for managing software installations and updates efficiently, ensuring system stability and security. The process includes setting up an HTTP or FTP delivery process and then local repository on the distribution server. 


Q. What is a client machine in the context of software repositories?

A client machine refers to a computer or system that connects to a software repository to download or update software packages. It uses client software like YUM or APT to manage installations and updates from these repositories.

Q. How can I monitor inbound packets to a client machine when downloading packages?

You can use network monitoring tools such as tcpdump or wireshark to monitor inbound packets. These tools can help you analyze traffic and ensure that your client machine is receiving data correctly from repository servers.

Q. How do I view a list of configured repositories on a client machine?

On Linux systems using YUM, you can view configured repositories by running the command yum repolist. This will display a list of all repositories available to your system.

Q. What are repo files and where are they located?

Repo files, typically ending in .repo, contain configuration information for software repositories. They are usually located in /etc/yum.repos.d/ for YUM-based systems.

Q. How can I access official repositories?

Official repositories can be accessed by configuring the correct repo files on your client machine. These files should point to the URLs where the official repositories are hosted.

Q. What should I do to install a single package from a repository?

To install a single package, use the package manager with the install command followed by the package name, like yum install [package_name] or apt-get install [package_name].

Q. How can I view the repository lists available for updates and installations?

Use the command yum repolist or apt list –all-versions to see all repositories and their status on your system.

Q. How do I create a list of all packages available from a specific repository?

You can list all packages from a specific repository using the command yum –disablerepo=”*” –enablerepo=”repo_name” list available.

Q. What is the vsftpd package, and why is it important?

The vsftpd package is a very secure and fast FTP daemon for Unix-like systems. It is important for setting up an FTP server, commonly used for hosting files, including software packages.

Q. How can I check the version of a package installed on my system? 

Use the command rpm -q [package_name] or dpkg -l [package_name] to check the installed version of a package on RPM-based or Debian-based systems, respectively.

Q. What are the steps to remove packages from my system? 

To remove packages, use yum remove [package_name] or apt-get remove [package_name]. Add the –purge option with apt-get to also remove configuration files.

Try this guide with our instant dedicated server for as low as 40 Euros