How to Install PostgreSQL and pgAdmin in RHEL 8

Pgadmin4 is an opensource web-based management tool for managing PostgreSQL databases. It’s a Python-based web-application developed using the flask framework at the backend and HTML5, CSS3, and Bootstrap on the frontend. Pgadmin4 is a rewrite of Pgadmin 3 which is written in C++ and ships with the following notable features:

Pgadmin4 Features

  • Sleek and revamped web interface with polished icons and panels.
  • Fully responsive web layout with dashboards for real-time monitoring.
  • Live SQL query tool/editor with syntax highlighting.
  • Powerful management dialogs and tools for common tasks.
  • Useful hints to get you started.
  • And so much more.

In this article, you will learn how to install PostgreSQL with pagAdmin4 in server mode running behind the Apache webserver using the WSGI module on RHEL 8.

Install PostgreSQL on RHEL 8

The first step in installing PgAdmin4 is to install the PostgreSQL database server. PostgreSQL is available in the Appstream repository in different versions. You can make your selection by enabling your preferred package using the dnf package manager.

To list the available modules for PostgreSQL, run the command:

# dnf module list postgresql
List Modules for Postgresql
List Modules for Postgresql

The output indicates that there are 3 versions available for download from the AppStream repository: version 9.6, 10, and 12. We can also see that the default version is Postgresql 10 as indicated by the [d] tag. This is what you would install by running the command below.

# dnf install postgresql-server

However, we want to install the latest version, which is PostgreSQL 12. Therefore, we will enable that module and override the default module stream. To do so, run the command:

# dnf module enable postgresql:12
Enable Module for PostgreSQL
Enable Module for PostgreSQL

Once you have enabled the module for Postgresql 12, proceed and install Postgresql 12 alongside its dependencies as shown.

# dnf install postgresql-server
Install PostgreSQL in RHEL 8
Install PostgreSQL in RHEL 8

Before anything else, you need to create a database cluster. A cluster comprises a collection of databases that are managed by a server instance. To create a database cluster, invoke the command:

# postgresql-setup --initdb

If everything went well, you should get the output below.

Initialize PostgreSQL Database
Initialize PostgreSQL Database

Once the cluster is created, you can now start and enable your PostgreSQL instance as shown:

# systemctl start postgresql
# systemctl enable postgresql

To confirm that Postgresql is up and running, execute:

# systemctl status postgresql
Verify PostgreSQL Status
Verify PostgreSQL Status

Installing Pgadmin4 in RHEL 8

To install Pgadmin4, first, add the external repository shown below.

# rpm -i

Next, run the command below to install pgadmin4 in server mode.

# dnf install pgadmin4-web  
Install Pgadmin4 in RHEL 8
Install Pgadmin4 in RHEL 8

Next, install the policycoreutils packages which provide the core utilities needed by SELinux.

$ sudo dnf install policycoreutils-python-utils
Install Python Policycoreutils in RHEL 8
Install Python Policycoreutils in RHEL 8

Once installed, run the Pgadmin4 setup script as shown. This is going to create a pgadmin user account, storage and log directories, configure SELinux and spin up the Apache webserver on which pgAdmin4 will run on.

# /usr/pgadmin4/bin/

When prompted, provide the required information and hit 'Y' to start the Apache webserver.

Run Pgadmin Setup Script
Run Pgadmin Setup Script

If you have a firewall running, open port 80 to allow web service traffic.

# firewall-cmd --add-port=80/tcp --permanent
# firewall-cmd --reload

Next, configure SELinux as shown:

# setsebool -P httpd_can_network_connect 1

To access pgadmin4, launch your browser and browse the URL shown.


Be sure to log in using the email address and the password that you provided when running the setup script.

pgadmin4 Login
pgadmin4 Login

This ushers you to the Pgadmin4 dashboard as shown below.

pgadmin4 Dashboard
pgadmin4 Dashboard

And that’s how you install Pgadmin4 in server mode. You can now create and manage PostgreSQL databases using the SQL editor and monitor their performance using the dashboards provided. This brings us to the end of this guide.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.