How to Create Local HTTP Yum/DNF Repository on RHEL 8

A software repository or “repo” is a central location for keeping and maintaining RPM software packages for Redhat Linux distribution, from which users can download and install packages on their Linux servers.

Repositories are generally stored on a public network, which can be accessed by multiple users on the internet. However, you can create your own local repository on your server and access it as a single user or allow access to other machines on your local LAN (Local Area Network) using HTTP web server.

The advantage of creating a local repository is that you don’t require an internet connection to install software packages or updates.

YUM (Yellowdog Updater Modified) or DNF (Dandified YUM) is a widely used software package management utility for RPM (RedHat Package Manager) based Linux systems, which makes software installation easy on Red Hat/CentOS Linux.

In this article, we will explain how to setup a local YUM/DNF repository on RHEL 8 using the installation DVD or ISO file. We will also show you how to find and install software packages on client RHEL 8 machines using Nginx HTTP server.

Our Testing Environment

Local Repository Server: RHEL 8 []
Local Client Machine: RHEL 8 []

Step 1: Install Nginx Web Server

1. First, install the Nginx HTTP server using the DNF package manager as follows.

# dnf install nginx
Install Nginx on RHEL 8

Install Nginx on RHEL 8

2. Once Nginx installed, you can start, enable the service to auto start at boot time and verify the status using the following commands.

# systemctl start nginx
# systemctl enable nginx
# systemctl status nginx
Verify Nginx on RHEL 8

Verify Nginx on RHEL 8

3. Next, you need to open Nginx ports 80 and 443 on your firewall.

# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload
Open Nginx Port on RHEL 8 Firewall

Open Nginx Port on RHEL 8 Firewall

4. Now you can verify that your Nginx server is up and running by going to the following URL on your web browser, a default Nginx web page will be displayed.

Verify Nginx Installation on RHEL 8

Verify Nginx Installation on RHEL 8

Step 2: Mounting RHEL 8 Installation DVD/ISO File

5. Create a local repository mount point under Nginx document root directory /var/www/html/ and mount the downloaded RHEL 8 DVD ISO image under /mnt directory.

# mkdir /var/www/html/local_repo
# mount -o loop rhel-8.0-x86_64-dvd.iso /mnt  [Mount Download ISO File]
# mount /dev/cdrom /mnt                       [Mount DVD ISO File from DVD ROM]

6. Next, copy ISO files locally under /var/www/html/local_repo directory and verify the contents using ls command.

# cd /mnt
# tar cvf - . | (cd /var/www/html/local_repo/; tar xvf -)
# ls -l /var/www/html/local_repo/
Verify Contents of RHEL 8 ISO Files

Verify Contents of RHEL 8 ISO Files

Step 3: Configuring Local Repository

7. Now it is time to configure the local repository. You need to create the local repository configuration file in the /etc/yum.repos.d/ directory and set the appropriate permissions on the file as shown.

# touch /etc/yum.repos.d/local-rhel8.repo
# chmod  u+rw,g+r,o+r  /etc/yum.repos.d/local-rhel8.

8. Then open the file for editing using your favorite command line text editor.

# vim /etc/yum.repos.d/local.repo

9. Copy and paste the following content in the file.



Save the changes and exit the file.

10. Now you need to install required packages for creating, configuring and managing your local repository by running the following command.

# yum install createrepo  yum-utils
# createrepo /var/www/html/local_repo/

Step 4: Testing Local Repository

11. In this step, you should run a cleanup of temporary files kept for repositories by using the following command.

# yum clean all
# dnf clean all

12. Then verify that the created repositories appear in the list of enabled repositories.

# dnf repolist
# dnf repolist  -v  #shows more detailed information 
Verify Local Repository in RHEL 8

Verify Local Repository in RHEL 8

13. Now try to install a package from the local repositories, for example install Git command line tool as follows:

# dnf install git
Install Package from Local Yum Repository

Install Package from Local Yum Repository

Looking at the output of the above command, the git package is being installed from the LocalRepo_AppStream repository as shown in the screenshot. This proves that the local repositories are enabled and are working fine.

Step 5: Setup Local Yum Repository on Client Machines

14. Now on your RHEL 8 client machines, add your local repos to the YUM configuration.

# vi /etc/yum.repos.d/local-rhel8.repo 

Copy and paste the configuration below in the file. Make sure to replace baseurl with your server IP address or domain.



Save the file and start using your local YUM mirrors.

15. Next, run the following command to see your local repos in the list of available YUM repos, on the client machines.

# dnf repolist
Verify Local Repository in RHEL 8 Client

Verify Local Repository in RHEL 8 Client

That’s all! In this article, we have shown how to create a local YUM/DNF repository in RHEL 8, using the installation DVD or ISO file. Do not forget to reach us via the feedback form below for any questions or comments.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

13 Responses

  1. Xavier NG says:

    It seems we missing one step: GPG-key generate?

    I got the error [Errno 14] PYCURL ERROR 22 – “The requested URL returned an error: 403 Forbidden” may be related to this

  2. stine says:

    How do you keep your local repo up-to-date? Under RHEL6 is was sane and logical. Under RHEL7 it was a mess. I’ve considered moving to Debian even before they were bought by IBM.

  3. JQ Chen says:

    I am using CentOS 8.

  4. JQ Chen says:

    I am at step “3. Next, you need to open Nginx ports 80 and 443 on your firewall.” I ran the first command “firewall-cmd –zone=public –permanent –add-service=http” but get the following error message. What went wrong? Thanks.

    "Traceback (most recent call last):
      File "/usr/bin/firewall-cmd", line 31, in 
        from firewall.client import FirewallClient, FirewallClientIPSetSettings, \
      File "/usr/lib/python3.6/site-packages/firewall/", line 33, in 
        from firewall.core.base import DEFAULT_ZONE_TARGET
    ModuleNotFoundError: No module named 'firewall.core'"
  5. Som says:

    I was able to setup the YUM repo on a server VM and then added the path in the repo file in the client VM.

    Now, on the server side, i can install any package and groups.

    On the client side however, only packages can be installed using YUM but listing or installing groups fail.

    ex: yum install httpd works flawlessly on the Client Side.

    However, yum groups list fails and yum group install "Server with GUI" and any other group fails as well.

    Here is the error that i get when i try to list groups on the client VM

    What am i missing here?

    • Ravi Saive says:


      First, register your RHEL 8 to RedHat Subscription, to get the package information.

      • Som says:

        Is the issue of “warning: no environments/groups match” related to subscription?

        I ask cause i was referring RedHat advisory and this is what i found

        Root Cause
        A comps file was not downloaded with reposync command.
        A comps file was not specified in createrepo command.

        Confirm that --downloadcomp option is used for reposync command, since the comps file is used for createrepo command.
        Confirm that -g option is used to specify the downloaded comps file in createrepo command.

        Since i copied all the files using the RHEL ISO, i did not use the reposync CMD to download the comps file, nor did i specify the comps file in the createrepo CMD

        Can you suggest how i can download the comps file and then attach it using createrepo?

        The exact syntax/CMD would be great.

        Thanks :)


    This tip work in centos and fedora?


Leave a Reply to Xavier NG Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.