Setting Up a YUM Repository (RHEL/CentOS)

A. Setting Up a YUM Repository (RHEL/CentOS)

1. Install and Configure a Web Server

Most repositories are served via HTTP. In this example, we’ll use Apache (httpd):

  1. Install Apache:bashCopyEditsudo yum install httpd -y
  2. Enable and start Apache:bashCopyEditsudo systemctl enable httpd sudo systemctl start httpd
  3. Verify that Apache is running:
    Open your browser and navigate to http://<your-server-IP>/ to see the Apache welcome page.

2. Create the Repository Directory

  1. Make a directory to hold your repository files:bashCopyEditsudo mkdir -p /var/www/html/myrepo
  2. Copy your RPM packages into this directory:bashCopyEditsudo cp /path/to/your/rpms/*.rpm /var/www/html/myrepo/

3. Generate Repository Metadata

  1. Install the createrepo tool:bashCopyEditsudo yum install createrepo -y
  2. Run createrepo in your repository directory:bashCopyEditsudo createrepo /var/www/html/myrepo This command creates a repodata directory with all the necessary metadata for the repository.

4. Set Proper Permissions

  1. Ensure Apache can read the files:bashCopyEditsudo chmod -R 755 /var/www/html/myrepo
  2. If SELinux is enabled, adjust the file context:bashCopyEditsudo chcon -R -t httpd_sys_content_t /var/www/html/myrepo

5. (Optional) Configure the Firewall

Make sure HTTP traffic is allowed:

  • For firewalld:bashCopyEditsudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload

Leave a comment