CentOSLinuxTutorials

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 the 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 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 the step-by-step installation of pgAdmin4 on a CentOS 8 server.

Prerequisites

  • A server running one of the following operating systems: CentOS 8.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

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 provided by the CentOS AppStream because the pgAdmin4 is 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

Don’t forget, to 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

If you have a firewall 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 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!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button