How to install PostgreSQL 14 and pgAdmin4 in CentOS 7
PostgreSQL is a sophisticated, widely-used, open-source, multi-platform, and advanced object-relational database system that is well-known for its proven architecture, data integrity, robust feature set, and extensibility.
pgAdmin is a web-based administration and management tool for the PostgreSQL database server that is advanced, open-source, and full-featured.
This article will show you how to install the PostgreSQL 12 database server as well as pgAdmin 4 in the CentOS 8 Linux platform.
Activate the official Yum Repository for PostgreSQL
$ yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Install both the server and client packages for PostgreSQL 14.
$ yum install -y postgresql14-server
After the installation is complete, start the PostgreSQL-12 service and set it to run automatically at system startup. Then verify that the service is up and operating, as well as enabled as indicated.
$ /usr/pgsql-14/bin/postgresql-14-setup initdb
$ systemctl enable postgresql-14
$ systemctl start postgresql-14
Check Status PostgreSQL
$ systemctl status postgresql-14
Then, for the PostgreSQL administrator database user/role, switch to the Postgres system account and generate a secure and strong password as follows.
Create roles for FreeSWITCH
$ su postgres -
postgres=# create role fsbkp with password 'fsbkp!' login;
postgres=# create role shah with password 'shah' login superuser createdb;
Create a database (for FreeSWITCH)
$ su postgres -
postgres=# create database freeswitch owner freeswitch;
Configure the Postgres server’s authentication for clients like pgAdmin. Password-based authentication is supported, and it employs one of the following methods: md5, crypt, or password.
Open `/var/lib/pgsql/14/data/pg_hba.conf` in your favorite editor and add the line
# IPv4 local connections:
host all all 10.10.110.45/24 md5
Open `/var/lib/pgsql/14/data/postgresql.conf` in your favorite editor and `uncomment` the line and replace localhost with `’*’`
listen_addresses = '*'
$ systemctl restart postgresql-14
Installation of pgAdmin4
To manage the PostgreSQL database from the web, we’ll install pgAdmin 4. The EPEL and pgAdmin Yum repositories, which include some of the dependencies, must first be enabled.
$ rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm
Use the commands below to install pgAdmin.
$ yum install -y pgadmin4
The pgadmin4 package includes a script for configuring the pgAdmin web service, which will create a user account for web authentication, configure SELinux policies, and deploy the pgAdmin web service using Apache.
Start the httpd service and set it to start automatically when the system boots up, then verify that it is up and operating as described.
$ systemctl start httpd.service
$ systemctl enable httpd.service
Change ownership and context
$ chown -R apache:apache /var/lib/pgadmin/*
$ chown -R apache:apache /var/log/pgadmin/*
$ chcon -t httpd_sys_rw_content_t /var/lib/pgadmin -R
$ chcon -t httpd_sys_rw_content_t /var/log/pgadmin –R
Open a browser and go to the following URL to get to the pgAdmin online interface. Use the email address and password you created when the login interface loads.