YUM Repository Installation for RedHat / CentOS / Fedora

 

There are several people still asking about how to create YUM Repository in their Local Linux distribution. So, here you go…

Step 1: Install “createrepo”

To create Custom YUM Repository we need to install additional software called “createrepo” on our cloud server. We can install “createrepo” by running the following command from console:

yum install createrepo

Step 2: Create Repository directory

We need to create a new directory that will be the location of our Custom YUM Repository and will hold the desired RPM package files. We can do this with the following command from console (choose a different /repository1 directory name if you like):

mkdir /repository1

Step 3: Put RPM files to Repository directory

If RPM package files are not yet present on our VPS we need to transfer them to our cloud server via FTP or SSH – use software like WinSCP (free SFTP client and FTP) or similar. We can also download RPM package files directly to our VPS (internet connection needed) with “wget” command from console (please change HTTP link accordingly):

wget http://mirror.lihnidos.org/CentOS/6/os/i386/Packages/NetworkManager-0.8.1-43.el6.i686.rpm

If RPM files are already present on our VPS, we need to Copy or Move these files to the newly created directory from “Step 2”. We can move RPM files with the following command from console (please change /path/to/rpm and /repository1 accordingly):

mv /path/to/rpm /repository1

We can copy RPM files with the following command from console (please change /path/to/rpm and /repository1 accordingly):

cp /path/to/rpm /repository1

Step 4: Run “createrepo”

Createrepo command reads through Custom YUM Repository directory from “Step 2” and creates a new directory called “repodata” in it. Repodata directory holds the metadata information for the newly created repository. Every time we add additional RPM package files to our Custom YUM Repository, we need to re-create Repository metadata with “createrepo” command. We can create new repository metadata by running the following command from console (please change /repository1 accordingly):

createrepo /repository1

Step 5: Create YUM Repository Configuration file

To start using the newly created Custom YUM Repository, we must create the corresponding YUM Repository Configuration file with .repo extension, which must be placed to /etc/yum.repos.d/ directory. Instructions to create YUM Repository Configuration file are covered in the first topic of this article called “YUM Repository Configuration File”.

Example Custom YUM Repository Configuration file:

/etc/yum.repos.d/custom.repo

[customrepo]
name=Custom Repository
baseurl=file:///repository1/
enabled=1
gpgcheck=0

You may also like...