• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

CentOS / RHEL : How to create and host yum repository over httpd

By admin

YUM (Yellowdog Updater, Modified) provide more services and functionality than is available with the rpm command and other RPM-based tools.
With Yum tools and plug-ins, you can:

  • List software packages, both installed and available, in local or remote repositories
  • Check for package dependencies (packages required to install a package)
  • Create new repositories and enable or disable access to existing repositories
  • Speed up package installation by using cached information (Yum cache)
  • Extend Yum’s functionality with plug-ins such as the downloadonly plug-in (to download a package without installing it)

Configuring yum repository over httpd

1. Create a directory for you local repository, e.g. /home/mypackage_dir/repository:

# mkdir /home/mypackage_dir/repository

2. Move the RPMs from DVD installation media into the directory you just created.

# cp /media/packages/* /home/mypackage_dir/repo

3. Assign appropriate ownership and filesystem permissions to the local repo directory.

# chown -R root.root /home/mypackage_dir/repo

4. Install the createrepo package if not installed yet, and run:

# createrepo /home/mypackage_dir/repo
# chmod -R o-w+r /home/mypackage_dir/repo

The RHEL5 version of createrepo require a full path be given as an option or the repository will not be created correctly . To avoid problems, make sure you always use a full path.

5. Create a repository configuration file, e.g. /etc/yum.repos.d/customrepo.repo containing below configuration.

[myrepo]
name=My custom repository
baseurl=file:///home/mypackage_dir/repository
enabled=1
gpgcheck=0

6. Before you configure the repository over httpd make sure it is working on the local host where is it hosted. Install your package using yum, replace package_name with the package you want to install and locate on mypackage_dir/repository :

# yum install package_name

Installing and configuring httpd

To use the yum repository configured on repo_server on client_system through http url please follow the below instructions.
1. Install and setup apache server.

# yum install httpd

2. You can either store the rpms in the default document root for httpd i.e. /var/www/html/repo or you can create a soft link between the document root and the repository directory. For the purpose of this post we are using a different directory that the document root.

# ln -s /var/www/html/repo /home/mypackage_dir/repo

3. Start the httpd service.

# service httpd start

Verify the repository access from the client system

1. Verify if you can access the repository url from the browser. The url in our case would be http://[repo_server-ip]/repo

2. On the client system configure .repo file as below. The .repo file can have any name of your choice and it recides in the directory /etc/yum.repos.d.

vi /etc/yum.repos.d/myrepo.repo
[repo_server-repo]
name=My RPM System Package Repo
baseurl=http://[repo_server-ip]/repo
enabled=1
gpgcheck=0

3. Then run the below command on client system followed by yum update to update the machine.

# yum repolist
# yum update
Note : The steps contained in this article work for any release, but the createrepo command must be run with the createrepo of the RHEL major release for its repository – this is due to formatting differences in rpm between major releases. This means you need to run createrepo on RHEL5 for a RHEL5 repository, on RHEL6 for a RHEL6 repository and so on.

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to create sparse files in Linux using ‘dd’ command
  2. CentOS / RHEL 5,6 : Change default kernel (boot with old kernel)
  3. CentOS / RHEL 7 : How to Reset root password
  4. How to Configure Network Teaming in CentOS/RHEL 7
  5. RHEL 7 – RHCSA Notes – vi/vim editor
  6. How to change the default password length in CentOS/RHEL/Fedora
  7. How to Disable Bluetooth in CentOS/RHEL 5,6,7
  8. CentOS / RHEL 7 : How to extract initramfs image and edit/view it
  9. What are the default parameters in pam_cracklib.so and their meaning
  10. Understanding /proc/meminfo file (Analyzing Memory utilization in Linux)

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable firewalld and nftables and use iptables instead in CentOS/RHEL 8
  • How to add an Ethernet connection using nmcli in CentOS/RHEL 7
  • How to set the order to load certain modules in CentOS/RHEL 7 and 8
  • How to configure initrd / initramfs to including kernel modules in CentOS/RHEL
  • How to configure systemd.path to trigger an event when any changes made to a directory
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary