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.
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 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
Don’t 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:
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:
If you have 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:
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.