Setting Up a Local YUM Repository server with Nginx Using RHEL ISO
Overview
First iso image file should be mounted as a seperate filesystem to access the package files. Then Createrepo and Nginx server should be installed and enabled. Then the Appstream and BaseOS directory have to be mounted on nginx's filepath. Firewall rules needed to be configured, so that Nginx can serve those repos. After that on that filepath "createrepo" need to be executed, this will make those directories package repository. Test this by configuring local yum configuration inside "/etc/yum.repos.d" directory.
Requirements
RHEL ISO image (e.g., rhel9.iso)
createrepo package
Nginx web server
Step 1: Mounting iso image as seperate filesystemto to access the package files
i)
mount -o loop /rhel9.iso /media
"-o" and "loop" are used to make this iso as file system and this will mount the files in /media
ii)
mkdir /packages
here Appstream and BaseOS directory need to be copied untill nginx is available.
iii)
cp -ar /media/Appstream /packages
iv)
cp -ar /media/BaseOS /packages
Coping the Appstream and BaseOS to /packages. "-ar" is used to copy archive and recursive files also Now you can ls inside /packages and also inside /packages/Appstream , /packages/BaseOS to verify.
Step 2: Installing Createrepo and Nginx package
i)
yum install createrepo
ii)
yum install nginx
iii)
systemctl enable --now nginx
To enable nginx, you can verify with
systemctl status nginx
Step 3: Moving files inside nginx's directory
i)
mkdir -p /usr/share/nginx/html/repo/appstream
"/usr/share/nginx/html/" till this already created.
ii)
mkdir -p /usr/share/nginx/html/repo/baseos
Need to create /repo and inside /repo , /appstream and /baseos need to be created
Step 4: Creating Repository Metadata
i)
createrepo /usr/share/nginx/html/repo/appstream
ii)
createrepo /usr/share/nginx/html/repo/baseos
Step 5: Set Nginx Permissions and SELinux Context
i)
chown -R nginx:nginx /usr/share/nginx/html/repo
If SELinux is installed then also execute this
ii)
chcon -R -t httpd_sys_content_t /usr/share/nginx/html/repo
Step 6: Opening http port in system's firewall to make repos accessable
i)
firewall-cmd --add-service=http -permanent
ii)
firewall-cmd --reload
Step 7: Testing this repos inside the system itself which will fetch from localhost
i)
cd /etc/yum.repos.d
here either "local.repo" file can be configured or this repo should be disabled and a new ".repo" file should be created, do vi and paste the below inside the ".repo" file
[InternalRepo_Appstream]
name=Internal_Repository_Appstream
baseurl=http://SYSTEM-IP/repo/appstream
enabled=1
gpgcheck=0
[InternalRepo_BaseOS]
name=Internal_Repository_BaseOS
baseurl=http://SYSTEM-IP/repo/baseos
enabled=1
gpgcheck=0
ii)
yum clean all
To clean the cache
iii)
yum repolist
To view the new repolist
iv)
yum install <PACKAGE-NAME>
To install the package
Step 8: Configure Client Machines
After successfully testing inside the satelite server itself with localhost now clients can be configured. Paste the following inside "/etc/yum.repos.d" either by creating new ".repo" file or replace the contents inside "local.repo".
[InternalRepo_Appstream]
name=Internal_Repository_Appstream
baseurl=http://SERVER-IP/repo/appstream
enabled=1
gpgcheck=0
[InternalRepo_BaseOS]
name=Internal_Repository_BaseOS
baseurl=http://SERVER-IP/repo/baseos
enabled=1
gpgcheck=0
**But ensure other repos should be disabled, like this
[Local_repo]
name=Local_Repository
baseurl=/repo_path
enabled=0 This should be "0"
gpgcheck=0
✅ Done!
Your local YUM satellite server is now configured and accessible to clients within your network via HTTP. This setup is especially useful for offline environments or restricted networks.