This page will be useful when creating your own/ custom yum repo and using it for your yum installations.
The standard RPM package management tool in Fedora, Red Hat Enterprise Linux, and CentOS is the yum package manager. Yum works quite well, if a little bit slower than other RPM package managers like apt4rpm and urpmi, but it is solid and handles dependencies extremely well. Using it with official and third-party repositories is a breeze to set up, but what if you want to use your own repository? Perhaps you manage a large computer lab or network and need to have — or want to have — certain packages available to these systems that you maintain in-house. Or perhaps you simply want to set up your own repository to share a few RPM packages.
The following are the steps to create your own repo.
Follow these steps on server machine.
- Creating your own yum repository is very simple, and very straightforward. In order to do it, you need the createrepo tool, which can be found in the createrepo package, so to install it, execute as root:yum install createrepo
- Install Apache HTTPD. Apache will act as a server to your clients where you want to install the packages.You may need to respond to some prompts to confirm you want to complete the installation.
yum install httpd
Creating a custom repository requires RPM or DEB files. If you already have these files, proceed to the next step. Otherwise, download the appropriate versions of the rpms and their dependencies.
Move your files to the web server directory and modify file permissions. For example, you might use the following commands:
mv /tmp/repo/* /var/www/html/repos/centos/6/7
- After moving files, visit http://:80/repos/centos/6/7
- Add a user and password to your apache directory. Execute the following command.
htpasswd -c /etc/repo repouser
where repouser is your username and you will be prompted for the password. /etc/repo can be any location where you want to store your password file which will be created after this command.
- Add authentication to your apache to add security. Add the following in your /etc/httpd/conf/httpd.conf file
AuthName “Password Required”
/var/www/html/repos is the path of your repo where you have your rpms stored. /etc/repo is the path of your password file.
- Execute the following command to create your repo.
- Add the port 80 in firewall to accept incoming requests to Apache.
sudo lokkit -p 80:tcp
- Start your apache server service httpd start
visit http://:80/repos/centos/6/7 in browser to verify that you see an index of files
Follow these steps on client machine.
- Rename/ delete the .repo files present in /etc/yum.repos.d/ to xyz.repo.bak
- Create files on client systems with the following information and format, where hostname is the name of the web server you created in the previous step.
the file name can be anything you want. Your repo will be refered to from this file.
- Add the following data in the newly created file or you can add it in /etc/yum.conf
name=CentOS-$releasever – Base
enabled = 1#released updates
name=CentOS-$releasever – Updates
#additional packages that may be useful
name=CentOS-$releasever – Extras
#additional packages that extend functionality of existing packages
name=CentOS-$releasever – Plus
#contrib – packages by Centos Users
name=CentOS-$releasever – Contrib
Here will be repouser or the user you added, is the password you entered. For ex: repouser@PassW0rd@172.16.120.50
- Execute the following commands to update yum.
yum clean all
- To use your custom repo execute the following command:
yum install packagename
For ex. yum install tomcat6
It will look for the packages in the newly created repo and install from there.
In case you want to add custom group to your yum repo, use the following steps:
Change directory to where your repo is(i.e where your rpms are stored).Ex. if the repo is at /var/www/html/repos/centos/6/7 thencd /var/www/html/repos/centos/6/7
Suppose your groupinstall command is as sudo yum groupinstall test-package and the mandatory packages required are yum and glibc and optional package is rpm
yum-groups-manager -n “test-package” –id=test-package –save=test-package.xml –mandatory yum glibc –optional rpm
- A file named test-package.xml will be created in your current working directory. Execute the following command.
sudo createrepo -g /path/to/xml/file /path/to/repo
Example: sudo createrepo -g /var/www/html/repos/centos/6/7/test-package.xml /var/www/html/repos/centos/6/7