Hamsa K
Editor
4 min read | 2 months ago

How to Install PgAdmin4 in CentOS 7

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 my server i have installed postgresql9.5 and installed pgadmin4

For reference follow our Article for Install PostgreSQL 11 on centos 7

To install postgresql9.5 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

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

Firewall

enable apache service in firewall to access pgadmin4 from remote machines

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

Selinux

disable selinux if it is enabled.

Now you can access pgadmin4 web interface with http://ip_address/pgadmin4

 

 



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy