How To Install pgAdmin4 on CentOS 8

Install pgAdmin4 on CentOS 8

In this tutorial we will show you how to install pgAdmin4 on CentOS 8. For those of you who didn’t know, pgAdmin is one of the most popular tools for managing PostgreSQL database. It was a feature-rich PostgreSQL administration tool. A complete rewrite from the previous pgAdmin version, built with Python and JavaScript. The pgAdmin4 designed for multiple PostgreSQL versions supports for PostgreSQL 9.2 and above. Multiplatform that can run on Linux, Mac, and Windows.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation pgAdmin4 on a CentOS 8 server.

Install pgAdmin4 on CentOS 8

Step 1. First, let’s start by ensuring your system is up-to-date.

sudo dnf clean all
sudo dnf update

Step 2. Installing the EPEL and PostgreSQL repository for CentOS 8.

Run the following command to install it:

sudo dnf install epel-release
sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Then, you must disable the default PostgreSQL repository provides by the CentOS AppStream because of the pgAdmin4 only available on the official PostgreSQL repository:

sudo dnf -qy module disable postgresql

Step 3. Installing pgAdmin4 no CentOS 8.

Install the pgAdmin4 package for CentOS 8 using the following command:

sudo dnf install pgadmin4

After that, go to the ‘/etc/httpd/conf.d’ directory and copy the sample configuration ‘pgadmin4.conf.sample’ to ‘pgadmin4.conf’:

cd /etc/httpd/conf.d/
cp pgadmin4.conf.sample pgadmin4.conf

Next, start and enable the httpd service, then check the httpd service:

systemctl enable --now httpd
systemctl status httpd

Step 4. Configure pgAdmin4.

Now we create the data directory and log directory for storing pgAdmin files:

mkdir -p /var/log/pgadmin4
mkdir -p /var/lib/pgadmin4

Dont forget, change the ownership of both pgAdmin4 data and log directories to the user ‘apache’:

chown -R apache:apache /var/lib/pgadmin4
chown -R apache:apache /var/log/pgadmin4

Next, edit the pgAdmin configuration ‘/usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py’ using nano editor:

nano /usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'

Next, create the user for the pgAdmin4 using the following command:

python3 /usr/lib/python3.6/site-packages/pgadmin4-web/setup.py

Dont forget, Change the ownership of both pgAdmin4 data and log directories to the user ‘apache’.

If you have firewalld configured, allow http traffic by running the following command:

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

Step 5. Accessing pgAdmin4.

open your web browser and go to the following address: http://your-server_ip/pgadmin4/ or http://localhost/pgadmin4/

Install pgAdmin4 on CentOS 8

Congratulations! You have successfully installed pgAdmin4. Thanks for using this tutorial for installing pgAdmin4 on your CentOS 8 system. For additional help or useful information, we recommend you to check the official pgAdmin4 website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!