Been a while since my previous post, but let’s hope the magic hasn’t rubbed off and I can pick things up where I left them. Today, I have a the fairly niche task to install NGINX on an offline RHEL system.
Why?
Well, because I’m working for a customer that doesn’t provide internet access or any proxy access to the Red Hat Enterprise Linux repositories. So I had to find a way to install NGINX onto this system without any internet access.
What I found after some research, if that I could download everything I needed onto a separate online RHEL system, copy the files over, and then install from those.
You can also read this on Medium!
FAQ
Install NGINX on an Offline RHEL System
To perform this process, we will need to have another RHEL system that has internet access. This system doesn’t need to have direct access to the desired RHEL system, but you will need a way to move the files over.
Essentially, we are creating an offline installer for NGINX and moving it over to the system that doesn’t have internet access.
For me, I setup a new Virtual Machine using a trial license of RHEL and then moved everything across to the customer’s system. I think you’ll be surprised by how simple this whole process is.
How to Setup WordPress Backups (FREE!)
Personally, I like my website. A lot. And I wouldn’t want one mistake to make…
MySQL 8.4 Replication with SSL on Ubuntu 22.02
So I recently wrote a post and made a YouTube video on setting up MySQL…
Gutenberg Just Broke my Website
More of a story and vent than an informative article. So to save you reading…
How to Design a Website in 5 Steps
How to fix MySQL Native Password Not Loaded on MySQL 8.4
This has been one of the most noticed changes when upgrading to MySQL 8.4. And…
How to setup MySQL Replication using SSL on Ubuntu
Let’s setup MySQL replication using SSL on Ubuntu. We’ll be using Ubuntu 22.04 LTS and…
Let’s get started!
Donor RHEL System
As mentioned before, you will need a RHEL system that. So let’s connect to that system and start:
First, we want to create a new directory. This will hold all the necessary files to move over to the offline RHEL system:
mkdir ~/nginx-offline-install
cd ~/nginx-offline-install
Now that you have a location, you might need to setup the RHEL subscription. This is something you’ll need to do if you have created a new donor system like I have:
#OPTIONAL
sudo dnf install epel-release (needs subscription manager to be setup)
After that is setup, we need to enable a specific repository in the RHEL system. This will enable the CodeReady Builder repository so that we can install the development tools and libraries needed for compiling the NGINX source code.
sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(uname -m)-rpms
To add more details, this is grabbing the CodeReady Builder repo for RHEL9. You might need to adjust this if you are using a different version of Red Hat.
We are also using $(uname -m) which will dynamically insert the systems architecture into the CodeReady Builder’s string. E.g. x86_64.
Finally, we need to download the NGINX packages without actually installing them:
sudo dnf install --downloadonly --downloaddir=./nginx-offline-install nginx
This works by using –downloadonly to only download the NGINX files. We set the –downloaddir so that we know where the NGINX files are being saved to. And finally we specify the NGINX package name at the end.
Transfer NGINX Packages
Once you’ve completed the package process on the donor system, you need to copy the nginx-packages folder to the offline RHEL system.
This can be done in a few ways, I used network access and SCP. But, if you have physical access you could also use USB, SMB file shares etc.
I’ll leave an example of the SCP command below in case that’s the method you go with:
sudo scp ./nginx-offline-install root@192.168.1.1:/home/nginx-offline-install
Install on the Offline RHEL System
Okay awesome, you’ve moved the nginx-packages directory to the offline RHEL system and you’re ready to install NGINX. Cool!
Let’s first navigate to the nginx-packages location using:
cd ~/nginx-offline-install
After this, we can use dnf again to install all the .rpm files, making sure to disable the repo for each:
sudo dnf install ./*.rpm --disablerepo=*
After this, NGINX should now be installed and ready to configure.
Conclusion
That’s everything you had to do to get NGINX installed onto a RHEL system that doesn’t have internet access. There is likely a very similar process to follow for other Linux distributions too, I might cover them in the future if you want?
You could possibly run into an issue where you don’t have permissions to the sudo command, in that case best of luck. Contact your in-house IT!
Enjoy! 🎉