October 21, 2021

How to install pgAdmin 4.30 on Centos 8

On This article we will discuss how to install pgAdmin 4.30 on Centos 8 operating system. pgAdmin 4 backend was written in Python, using Flask and Qt framework.



Introduction

pgAdmin is a management tool for PostgreSQL and derivative relational databases such as EnterpriseDB’s EDB Advanced Server. It may be run either as a web or desktop application. On this article we will discuss how to install the pgAdmin version 4.30, the latest version which was released 28 January, 2021. This latest version includes 38 bug fixes and new features, as noted on pgAdmin official page release notes. Notable changes in pgAdmin version 4.30 include : ERD Tool (Beta), Kerberos Support and Add a container option (PGADMIN_DISABLE_POSTFIX) to disable the Postfix server.

pgAdmin 4.30 Installation On CentOS 8

The pgAdmin installation on CentOS 8 will be consist of several steps which will be described below. Before installation is begun, then we have to fulfill several prerequisites. The installation process will be as follow :

  1. Prerequisites
  2. Enabling Epel and PowerTools Repostiory
  3. Install pgAdmin
  4. Configuring pgAdmin
  5. Accessing pgAdmin

1. Prerequisites

The first thing to do when installing pgAdmin is to make sure there is a PostrgreSQL database running on the system. If there is no PostgreSQL database, then we must first install postgreSQL. An article regarding the PostgreSQL installation can be found in PostgreSQL (Postgres) Installation on CentOS 8 article. We also need web server installed on the system, currently we had apache http web server. For httpd web server installation on CentOS 8 can be found on How To Install Apache httpd Webserver On CentOS 8 article. Then we need a root or an ordinary user with sudo privilege and sufficient storage for accommodating pgAdmin binary files.

2. Enabling Epel and PowerTools Repostiory

pgAdmin requires some dependencies to run smoothly, for this purpose we hav to to enable the EPEL and PowerTools repositories. Epel repository will be installed on our CentOS 8 system by submitting command line : sudo dnf install epel-release.

[ramans@localhost ~]$ sudo dnf install epel-release
 [sudo] password for ramans: 
 CentOS Linux 8 - AppStream                                                                           349  B/s | 4.3 kB     00:12    A
 CentOS Linux 8 - AppStream                                                                           323 kB/s | 6.3 MB     00:19    
 CentOS Linux 8 - BaseOS                                                                              3.8 kB/s | 3.9 kB     00:01    
 CentOS Linux 8 - BaseOS                                                                              112 kB/s | 2.3 MB     00:20    
 CentOS Linux 8 - Extras                                                                              1.7 kB/s | 1.5 kB     00:00    
 Docker CE Stable - x86_64                                                                            1.5 kB/s | 3.5 kB     00:02    
 Docker CE Stable - x86_64                                                                             18 kB/s | 7.8 kB     00:00    
 pgadmin4                                                                                             1.8 kB/s | 2.9 kB     00:01    
 pgadmin4                                                                                              44 kB/s | 501 kB     00:11    
 PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64                                                    1.1 kB/s | 3.0 kB     00:02    
Enable EPEL on CentOS 8
Enable EPEL on CentOS 8

Enable PowerTools repository by submitting command line : sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm.

[ramans@localhost ~]$ sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
 Extra Packages for Enterprise Linux Modular 8 - x86_64                                               163 kB/s | 536 kB     00:03    
 Extra Packages for Enterprise Linux 8 - x86_64                                                        47 kB/s | 8.8 MB     03:12    
 Last metadata expiration check: 0:00:01 ago on Mon 01 Feb 2021 06:35:02 AM PST.
 pgdg-redhat-repo-latest.noarch.rpm                                                                   5.9 kB/s |  11 kB     00:01    
 Dependencies resolved.
Enable PowerTools Repository
Enable PowerTools Repository

3. Installing pgAdmin 4 on CentOS 8

Before we pgAdmin installation is initiated, first we have to disable the PostgreSQL service, by submitting command line : sudo dnf -qy module disable postgresql then we do the installation by submitting command line : sudo dnf install pgadmin4. These two command are as follow :

[ramans@localhost ~]$ sudo dnf -qy module disable postgresql
 [sudo] password for ramans: 
 [ramans@localhost ~]$ sudo dnf install pgadmin4
 Last metadata expiration check: 0:10:52 ago on Mon 01 Feb 2021 06:35:02 AM PST.
 Dependencies resolved.
  Package                                          Architecture        Version                         Repository                Size
 Installing:
  pgadmin4                                         x86_64              4.30-1.rhel8                    pgdg-common               18 k
 Installing dependencies:
  libsodium                                        x86_64              1.0.18-2.el8                    epel                     162 k
  pgadmin4-docs                                    noarch              4.30-1.rhel8                    pgdg-common               50 M
  pgadmin4-python3-Flask-Mail                      noarch              0.9.1-4.rhel8.1                 pgdg-common               24 k
  pgadmin4-python3-alembic                         noarch              0.9.7-4.rhel8                   pgdg-common              268 k
  pgadmin4-python3-dateutil                        noarch              1:2.8.0-1.rhel8                 pgdg-common              290 k
  pgadmin4-python3-flask                           noarch              1:1.0.2-1.rhel8                 pgdg-common              153 k
  pgadmin4-python3-flask-babelex                   noarch              0.9.4-1.rhel8                   pgdg-common               23 k
Install pgAdmin 4.30
Install pgAdmin 4.30

Then installation was completed done as installation log shown below :

Installed:
   libsodium-1.0.18-2.el8.x86_64                                     pgadmin4-4.30-1.rhel8.x86_64                                     
   pgadmin4-docs-4.30-1.rhel8.noarch                                 pgadmin4-python3-Flask-Mail-0.9.1-4.rhel8.1.noarch               
   pgadmin4-python3-alembic-0.9.7-4.rhel8.noarch                     pgadmin4-python3-dateutil-1:2.8.0-1.rhel8.noarch                 
   pgadmin4-python3-flask-1:1.0.2-1.rhel8.noarch                     pgadmin4-python3-flask-babelex-0.9.4-1.rhel8.noarch              
   pgadmin4-python3-flask-compress-1.4.0-1.rhel8.noarch              pgadmin4-python3-flask-gravatar-0.5.0-1.rhel8.1.noarch           
   pgadmin4-python3-flask-login-0.4.1-1.rhel8.noarch                 pgadmin4-python3-flask-migrate-2.4.0-1.rhel8.noarch              
   pgadmin4-python3-flask-paranoid-0.2-1.rhel8.1.noarch              pgadmin4-python3-flask-principal-0.4.0-14.rhel8.1.noarch         
   pgadmin4-python3-flask-security-too-3.3.3-1.rhel8.noarch          pgadmin4-python3-flask-sqlalchemy-2.4.1-1.rhel8.noarch           
   pgadmin4-python3-flask-wtf-0.14.3-2.rhel8.noarch                  pgadmin4-python3-passlib-1.7.2-1.rhel8.noarch                    
   pgadmin4-python3-psutil-5.7.0-1.rhel8.x86_64                      pgadmin4-python3-simplejson-3.16.0-1.rhel8.x86_64                
   pgadmin4-python3-six-1.12.0-3.rhel8.noarch                        pgadmin4-python3-speaklater-1.3-3.rhel8.1.noarch                 
   pgadmin4-python3-sqlalchemy-1.3.13-2.rhel8.x86_64                 pgadmin4-python3-sqlparse-0.3.0-1.rhel8.noarch                   
   pgadmin4-python3-sshtunnel-0.3.1-1.rhel8.noarch                   pgadmin4-python3-werkzeug-0.15.4-1.rhel8.noarch                  
   pgadmin4-python3-wtforms-2.2.1-1.rhel8.noarch                     pgadmin4-pytz-2020.1-1.rhel8.noarch                              
   pgadmin4-web-4.30-1.rhel8.noarch                                  python3-babel-2.5.1-5.el8.noarch                                 
   python3-bcrypt-3.1.6-2.el8.1.x86_64                               python3-blinker-1.4-4.el8.noarch                                 
   python3-click-6.7-8.el8.noarch                                    python3-dns-1.15.0-10.el8.noarch                                 
   python3-email-validator-1.0.5-2.el8.noarch                        python3-flask-1:0.12.2-4.el8.noarch                              
   python3-itsdangerous-0.24-14.el8.noarch                           python3-jinja2-2.10.1-2.el8_0.noarch                             
   python3-ldap3-2.8.1-2.el8.noarch                                  python3-mako-1.0.6-13.el8.noarch                                 
   python3-markupsafe-0.23-19.el8.x86_64                             python3-mod_wsgi-4.6.4-4.el8.x86_64                              
   python3-paramiko-2.4.3-1.el8.noarch                               python3-psycopg2-2.8.6-1.rhel8.x86_64                            
   python3-pyasn1-0.3.7-6.el8.noarch                                 python3-pynacl-1.3.0-5.el8.x86_64                                
   python3-werkzeug-0.12.2-4.el8.noarch                             
 Complete!

Because we are running the pgAdmin web server on http server, then we have to starting it up, by command line : sudo systemctl start httpd and verify it by submitting comand line : sudo systemctl status httpd.

[ramans@localhost ~]$ sudo systemctl start httpd
[ramans@localhost ~]$ sudo systemctl status httpd
 ● httpd.service - The Apache HTTP Server
    Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
    Active: active (running) since Mon 2021-02-01 06:55:43 PST; 15s ago
      Docs: man:httpd.service(8)
  Main PID: 5205 (httpd)
    Status: "Running, listening on: port 80"
     Tasks: 213 (limit: 49341)
    Memory: 56.1M
    CGroup: /system.slice/httpd.service
            ├─5205 /usr/sbin/httpd -DFOREGROUND
            ├─5212 /usr/sbin/httpd -DFOREGROUND
            ├─5213 /usr/sbin/httpd -DFOREGROUND
            ├─5214 /usr/sbin/httpd -DFOREGROUND
            └─5215 /usr/sbin/httpd -DFOREGROUND
Starting http web server
Starting http web server

4. Configuring pgAdmin

The pgAdmin configuration process will be consisting of serveral steps as described below :

  1. On this section we will configure the pgAdmin with its default parameters while installation. The configuration file is located on /etc/httpd/conf.d/pgadmin4.conf file. We will copy from the sample file.
[ramans@localhost ~]$ sudo cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf

The content of file is :

LoadModule wsgi_module modules/mod_wsgi.so
 WSGIDaemonProcess pgadmin processes=1 threads=25
 WSGIScriptAlias /pgadmin4 /usr/lib/python3.6/site-packages/pgadmin4-web/pgAdmin4.wsgi
<Directory /usr/lib/python3.6/site-packages/pgadmin4-web>
        WSGIProcessGroup pgadmin
        WSGIApplicationGroup %{GLOBAL}
            <IfModule mod_authz_core.c>
                     # Apache 2.4 
                     Require all granted         
            </IfModule>
            <IfModule !mod_authz_core.c>
                     # Apache 2.2                 
                     Order Deny,Allow                 
                     Deny from All                 
                     Allow from 127.0.0.1                 
                     Allow from ::1         
           </IfModule>
</Directory>
 
/etc/httpd/conf.d/pgadmin4.conf file
/etc/httpd/conf.d/pgadmin4.conf file

2. To take effect and ensure if the syntax is OK then we have to validate and restart httpd web server service.

[ramans@localhost ~]$ httpd -t
[ramans@localhost ~]$ sudo systemctl restart httpd

3. The next step is to create a new a directory for pgAdmin logs and libraries. The command line is as follow :

[ramans@localhost ~]$ sudo mkdir -p /var/lib/pgadmin4/ /var/log/pgadmin4/

4. After creating the new two directories the we have to declare the location/path of the log file, SQLite database, session database and storage in the Python configuration file for pgAdmin in the file. The file is located on /usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py.

[ramans@localhost ~]$ sudo vi /usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py

The content of this file is as shown below :

HELP_PATH = '/usr/share/doc/pgadmin4-docs/en_US/html'
 UPGRADE_CHECK_ENABLED = False
 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'
/usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py file
/usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py file
pgAdming 4.30 configuration steps
pgAdming 4.30 installation | configuration steps

5. To access pgAdming web, we need to create a user account used to authenticate in the web interface and also create the configuration database. This step is done by submitting command line : sudo python3 /usr/lib/python3.6/site-packages/pgadmin4-web/setup.py. We will create a user by using email address as admin@otodiginet.com and supply a new password for it.

[ramans@localhost ~]$ sudo python3 /usr/lib/python3.6/site-packages/pgadmin4-web/setup.py
 NOTE: Configuring authentication for SERVER mode.
 Enter the email address and password to use for the initial pgAdmin user account:
 Email address: admin@otodiginet.com
 Password: 
 Retype password:
 pgAdmin 4 - Application Initialisation
pgAdmins 4.30 | create user
pgAdmins 4.30 | create user

6. Change user ownership for the directory tha have been crated.

[ramans@localhost ~]$ sudo chown -R apache:apache /var/lib/pgadmin4 /var/log/pgadmin4
[ramans@localhost ~]$ sudo chown -R apache:apache /var/lib/pgadmin4 /var/log/pgadmin4

7. We have to set the correct SELinux context of the pgAdmin log directories. And allow HTTPD scripts and modules (pgAdmin in this case)to connect to the network.

[ramans@localhost ~]$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/lib/pgadmin4(/.)?" [ramans@localhost ~]$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/log/pgadmin4(/.)?"
 [ramans@localhost ~]$ sudo restorecon -Rv /var/lib/pgadmin4/
 Relabeled /var/lib/pgadmin4 from unconfined_u:object_r:var_lib_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0
 Relabeled /var/lib/pgadmin4/sessions from unconfined_u:object_r:var_lib_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0
 Relabeled /var/lib/pgadmin4/storage from unconfined_u:object_r:var_lib_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0
 Relabeled /var/lib/pgadmin4/pgadmin4.db from unconfined_u:object_r:var_lib_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0
 [ramans@localhost ~]$ sudo restorecon -Rv /var/log/pgadmin4/
 Relabeled /var/log/pgadmin4 from unconfined_u:object_r:var_log_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0
 Relabeled /var/log/pgadmin4/pgadmin4.log from unconfined_u:object_r:var_log_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0

5. Accessing pgAdmin 4.30 Web Interface

On this section, we will access the pgAdmin 4.30 web interface for the first time. We will use the web browser and hit the url : http://ip_address_or_name/pgadmin4.

pgAdmin 4.30 web interface
pgAdmin 4.30 web interface

We will supply the username and password as we have created on section Cofiguring pgAdmin subsection 5.

pgAdmin 4.30 web dashboard
pgAdmin 4.30 web dashboard for the first time

Conclussion

So far, we have installed pgAdmin 4.30 on CentOS 8 operating system completed done successfully. For any other things related to pgAdmin application can refer to th pgAdmin official website. Have a nice day and thank you.

Share this article via :

One thought on “How to install pgAdmin 4.30 on Centos 8

Leave a Reply

Your email address will not be published. Required fields are marked *