Install PgAdmin4 on centos 7/RHEL7
pgAdmin is a free and open source management tool for postgresql.It can be installed in multiple OS platforms like windows,Linux,Unix etc to manage postgrsql 9.2 and above versions.
In this tutorial, we will install and configure pgadmin4 on centos 7 system.In my server i have installed postgresql 9.5 and installed pgadmin4 versions.
For reference follow our Article to Install PostgreSQL 11 on centos 7
To install postgresql 9.5,you can follow below steps.
1) yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7.3-x86_64/pgdg-centos95-9.5-3.noarch.rpm
2) yum groupinstall "PostgreSQL Database Server 9.5 PGDG"
3) /usr/pgsql-9.5/bin/postgresql95-setup initdb
4) systemctl start postgresql-9.5
once postgresql service is started install pgadmin4
yum install pgadmin4
start and enable httpd service if it is not installed and started previously
systemctl start httpd
systemctl enable httpd
Also Read -> How to Install Python3 on Centos 7
Configure PgAdmin 4
we need to few configuration changes before accessing pgadmin
copy pgadmin 4 sample configuration file like below.
cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf
Create a pgAdmin log and data directories and set their ownsership
mkdir -p /var/lib/pgadmin4/
mkdir -p /var/log/pgadmin4/
chown -R apache:apache /var/lib/pgadmin4/*
chown -R apache:apache /var/log/pgadmin4/*
Then edit below file
vi /usr/lib/python2.7/site-packages/pgadmin4-web/config_distro.py
Add below lines to above file
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'
Now run below command to create user account for the pgAdmiweb interface.
python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py
It will ask you to enter email id and password. After that restart apache service.
systemctl restart httpd
Also Read -> How to Configure RAID1 on Centos 7
Firewall and Selinux
if firewall service is running on your system, then enable apache service in firewall to access pgadmin4 from remote machines
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
you can disable selinux if it is enabled.
Access PgAdmin4
Now you can access pgadmin4 web interface with http://ip_address/pgadmin4
That's it. now you have successfully installed pgadmin4 on centos 7 system.
Also Read -> How to Install Webmin on Centos 7