PostgreSQL is one of the most loved databases, especially by developers, for its simplicity, easy configurations, and massive community support. It’s an open-source powerhouse known for handling everything from small projects to large-scale applications.
While major cloud providers, like AWS, Google, and Microsoft offer robust solutions for hosting databases on the cloud, not all businesses can or want to go this route
Many companies, choose to store their databases in secure, closed environments—machines without internet access or outside the cloud. This is often done to maintain tight control over sensitive data and to meet strict security requirements. However installing PostgreSQL in a restricted, offline environment can be a real challenge, as it limits access to typical installation tools.
Recently, I worked on a client project with a similar setup—a secure, offline environment without internet access—where we needed to install and configure PostgreSQL from scratch. If you’re facing the challenge of setting up PostgreSQL in a closed environment, this blog will guide you through the process step-by-step.
Installing PostgreSQL Using RPM Packages
We will be using PostgreSQL RPMs on RHEL to install PostgreSQL without internet access. There are two methods to achieve this. The first option is to visit this link https://download.postgresql.org/pub/repos/yum/15/redhat/rhel-9.4-x86_64/
and download each RPM package individually. However, this approach can lead to missing dependencies, You might forget which packages are necessary or overlook certain dependencies. If a required RPM is missing from the provided URL, you’ll have to search the internet to find the correct RPM.
The second option is to set up an alternative machine with internet access and use a few yum commands to download the necessary RPMs along with all their dependencies. Once you have downloaded the RPMs, you can upload them to the target host. This method ensures that all required RPMs are included, saving you the hassle of searching for packages online and significantly reducing the time spent on the installation process.
On the host with internet
Run yum deplist command to find out all the required packages to install PostgreSQL (Make sure the PGDG repository is already configured on your host)
Read more here: https://www.postgresql.org/download/
sudo yum deplist postgresql17-server
Once you get the list then you can run this command to download the packages
sudo yum install --downloadonly --downloaddir=postgres-rpms/ postgresql17-server
Where postgres-rpms is the local directory name on the filesystem where all the required RPMs will be downloaded
Once this is done and you have the required list of RPMs go ahead and upload them to the server without internet access and install the RPMs with
sudo rpm -ivsh *.rpm
Or run
sudo yum localinstall *.rpm
This made the PostgreSQL installation quite straightforward, as it only required an additional 3 or 4 packages. However, in our upcoming blogs, we will explore how to install PostGIS, which has a significantly larger number of dependencies, and discuss effective methods for installing PostGIS without internet access.