How To Install pgAdmin 4 on CentOS 7 / RHEL 7 & Fedora 29 / Fedora 28

Install pgAdmin 4

Once you have PostgreSQL repository configured on your system, run the following command to install pgAdmin 4.

### RHEL / CentOS ###

yum -y install pgadmin4

### Fedora ###

dnf -y install pgadmin4

Configure pgAdmin 4

We would need to do a few configuration changes prior to accessing the pgAdmin 4.

Copy the pgAdmin 4 sample configuration.

cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf

Create a pgAdmin log and data directories.

mkdir /var/log/pgadmin4/
mkdir /var/lib/pgadmin4/

Create/Edit file.

vim /usr/lib/python2.7/site-packages/pgadmin4-web/

Add the following settings. A

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'

after the existing one:

import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))

Change permissions of directories so that Apache can write data into it. B

chown -R apache:apache /var/lib/pgadmin4/*
chown -R apache:apache /var/log/pgadmin4/*

Run the following command to create a user account for the pgAdmin 4 web interface. C

python /usr/lib/python2.7/site-packages/pgadmin4-web/


NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: [email protected]
Password: xxxxxxxxx
Retype password: xxxxxxxxx
pgAdmin 4 - Application Initialisation

Restart the Apache web service.

systemctl restart httpd

My https configuration file for Apache

For CentOS 7:

<VirtualHost *:80>
        Redirect permanent /
<VirtualHost *:443>
        LoadModule wsgi_module modules/
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/
        SSLCertificateKeyFile /etc/ssl/certs/
        SSLCACertificateFile /etc/ssl/certs/
        WSGIDaemonProcess pgadmin processes=1 threads=25
        WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi

        <Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
                WSGIProcessGroup pgadmin
                WSGIApplicationGroup %{GLOBAL}
                <IfModule mod_authz_core.c>
                        # Apache 2.4
                        Require all granted
                <IfModule !mod_authz_core.c>
                        # Apache 2.2
                        Order Deny,Allow
                        Deny from All
                        Allow from
                        Allow from ::1

if you have this error in your Apache log file : Fatal Python error: PyEval_AcquireThread: NULL new thread state

is because mod_python have to removed from the modules

After the installation when you do an update the steps are: A, B, C


Leave a Reply