Creating Local Yum Repository on RED HAT or CentOS

Lets look at the steps required to setup local yum repository. We will create local repo called demolocal. We will then copy single package iperf3-3.0.11-1.fc22.x86_64.rpm as an example and install it from our demolocal repo.

Lets create directory called /var/local

#mkdir -p /var/local

Now we will download package called iperf3-3.0.11-1.fc22.x86_64.rpm into this directory

Install package called createrepo

#yum -y install createrepo

Execute createrepo on directory /var/local

#createrepo -v /var/local

Now lets create definition file for demolocal repository

#vi /etc/yum.repos.d/demolocal.repo
[demolocal]
name=demo local repo
baseurl=file:///var/local/
enabled=1
gpgcheck=0

Clean up yum cache

#yum clean all

Lets confirm to make sure this repo is created

#yum -v repolist
....
Repo-id      : demolocal
Repo-name    : demo local repo
Repo-revision: 1457622346
Repo-updated : Thu Mar 10 10:05:46 2016
Repo-pkgs    : 1
Repo-size    : 70 k
Repo-baseurl : file:///var/local/
Repo-expire  : 21,600 second(s) (last: Thu Mar 10 10:06:00 2016)
Repo-filename: ///etc/yum.repos.d/demolocal.repo

Now we can view packages available in our demolocal repository

#yum --disablerepo="*" --enablerepo="demolocal" list available
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
iperf3.x86_64  3.0.11-1.fc22   demolocal

And finally lets install our iperf3 package from demolocal repo.

#yum install iperf3 -y