How to Install pgAdmin on CentOS 8

Install pgAdmin on CentOS 8

In this article, we will have explained the necessary steps to install and configure pgAdmin on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

pgAdmin pgAdmin is the leading graphical Open Source management, development and administration tool for PostgreSQL. pgAdmin4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL database.

Install pgAdmin on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf install epel-release
sudo dnf update

Step 2. Install PostgreSQL.

PostgreSQL is included in the default repositories of CentOS 8, and can be installed using the following dnf command:

dnf install @postgresql

Once the installation is done, you can initialize the database using the below command:

/usr/bin/postgresql-setup --initdb

To start and enable PostgreSQL you need to use the systemctl command:

sudo systemctl start postgresql    ## <-- start the server ##
sudo systemctl stop postgresql     ## <-- stop the server ##
sudo systemctl restart postgresql  ## <-- resstart the server ##
sudo systemctl status postgresql   ## <-- get status of the server ##

Step 3. Install pgAdmin on the CentOS system.

To install pgAdmin4 on CentOS 8 we need to add an external repository, so execute the following command:

sudo rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-1-1.noarch.rpm

Then install the pgAdmin package:

sudo dnf install pgadmin4-web

Step 4. Configure pgAdmin.

Once we are done installing pgAdmin4, we need to configure the pgAdmin4 by setting up the initial pgAdmin user account and the Apache Web server as below:

sudo /usr/pgadmin4/bin/setup-web.sh
Setting up pgAdmin 4 in web mode on a Redhat platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: your-email-address
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================

Creating storage and log directories...
Configuring SELinux...
The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Would you like to continue (y/n)? y
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Apache successfully enabled.
Apache successfully started.
You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4

Step 5. Configure Firewall.

If the Firewall is enabled, execute the following command to enable HTTP service:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Step 6. Access pgAdmin 4.

To access the pgAdmin web interface, open a browser, and navigate using the following URL:

http://your-ip-address/pgadmin4
OR
http://localhost/pgadmin4

Congratulation, you have learned how to install and configure pgAdmin 4 on CentOS 8. If you have any questions, please leave a comment below.