People working on linux may be familiar with yum command.

Yum install <package name>  is a command that is used frequently for installing packages from a remote repository.

YUM stands for Yellowdog Update, Modifier.

YUM is a program that manages updates, installation and removal for RedHat package manager (RPM) systems.

Yum install will pick the repository url from /etc/yum.repos.d/ and download the package and install it in the machine.

Normally yum will work in machines having internet access. But if we want to install packages in isolated environments, normal yum install will not work, because the remote repository may not be accessible in the isolated environment.

In these cases, we have to set up a local yum repository.

Local repository is an exact copy of the remote repository that is made available in the isolated environment.

In most of the companies we need to set up a local repository for doing the yum installations.

Creating a local yum repository is very simple. This document helps you to create a local yum repository.


A RHEL or CentOS linux machine


1)      Installing and Starting Webserver  (httpd)

We need a webserver for creating a repository. So ensure that httpd is installed and running on the repository linux machine. If it is not there, download the httpd package and install it manually. If it is not started, start it manually.

rpm –ivh  <package-name>

then start the httpd service

/etc/init.d/httpd start  or service httpd start

2)      Creating a YUM Repository

For creating a repository, we need to install two packages

a)      createrepo

b)      yum-utils

Download and install these packages manually.

After this create a folder in with the name of your repository in /var/www/html/.

mkdir /var/www/html/<repo-name>

Note: the /var/www/html folder structure will be available only after starting httpd service.

Copy the packages that you want to be available in the repository as subfolders in the /var/www/html/<repo-name> directory.

After this go inside the <repo-name> directory and execute the following command.

$ createrepo .

This will create repodata of the repository.

Then try this repository from your web browser.

http://<ipaddress of webserver machine>/reponame/

You will be able to see all the packages. You can add as many packages into the repository. So that it can be made available in all machines using the url.

Note: These repository directory permissions should be set in a way that everybody can access. Better to give 755 permission.

3)      Create the repo file

The packages present in the local repository can be made available to other machines by creating a repo file for this repository in the respective machines.

In the repo file, we are mentioning the url of this repository. This repo file is created in /etc/yum.repos.d/ directory.

Create a file <repo-name>.repo

Add the below contents to the file and save it.


name=Local Yum Repository

baseurl=http://<ipaddress of webserver machine>/<path to repo>

gpgcheck = 0

After adding the repo file, execute the following command.

$ yum clean all

This will clear all the temporary data saved about the previous repositories. That is just like refreshing.

With this you can create a repository and keep packages inside it and make it available to multiple machines. If you want a local copy of a remote repository, you can refer the steps below.

4)      Syncing a remote repository with the local repository

If you want to create a local copy of a remote repository, we can create it by using reposync command.

This needs internet connection, because we are copying the repository from a remote location to our local machine.

Create a repo file in /etc/yum.repos.d/ with the url of the remote repository


name=Remote repository


gpgkey=http://<gpg-key url>

gpgcheck = 1

Then create a directory for that repository, go to that directory

then do the following commands

yum clean all

reposync  –r  repo-name .

The repo-name is the repo-name mentioned in the repo file.

This will download the remote repository in our local machine. This will take time depending upon the size of the repository and speed of internet connection.

Copy this downloaded repository to /var/www/html/ directory and execute a createrepo, then this repository can be accessible from any machines (follow steps 2 and 3).