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):
- Install Apache:bashCopyEdit
sudo yum install httpd -y - Enable and start Apache:bashCopyEdit
sudo systemctl enable httpd sudo systemctl start httpd - Verify that Apache is running:
Open your browser and navigate tohttp://<your-server-IP>/to see the Apache welcome page.
2. Create the Repository Directory
- Make a directory to hold your repository files:bashCopyEdit
sudo mkdir -p /var/www/html/myrepo - Copy your RPM packages into this directory:bashCopyEdit
sudo cp /path/to/your/rpms/*.rpm /var/www/html/myrepo/
3. Generate Repository Metadata
- Install the
createrepotool:bashCopyEditsudo yum install createrepo -y - Run
createrepoin your repository directory:bashCopyEditsudo createrepo /var/www/html/myrepoThis command creates arepodatadirectory with all the necessary metadata for the repository.
4. Set Proper Permissions
- Ensure Apache can read the files:bashCopyEdit
sudo chmod -R 755 /var/www/html/myrepo - If SELinux is enabled, adjust the file context:bashCopyEdit
sudo chcon -R -t httpd_sys_content_t /var/www/html/myrepo
5. (Optional) Configure the Firewall
Make sure HTTP traffic is allowed:
- For firewalld:bashCopyEdit
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload