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. It may be run either as a web or desktop application.
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 01 January, 2021. This latest version includes 38 bug fixes and new features, as noted on pgAdmin official page release notes.
PgAdmin 4.30 Installation On CentOS 8
Before we are going to install pgAdmin on CentOS 8, there are several prerequisite to be fulfilled, as shown below :
Prerequisites
- CentOS 8 System with sufficient disk space
- non-root user with administrative privileges
- firewall configured with firewalld
The pgAdmin 4.3 installation will be consist of several steps :
- Enable Epel Repository
- Enable pgAdmin Repository
- Install pgAdmin
- Configuring pgAdmin
- Accessing pgAdmin 4.30 web
Detailed explanation of each item will be explained in the following sub-chapters.
1. Enable Epel Repository
On this stage, we will enable Epel (Extra Packages for Enterprise Linux) repository on our CentOS 8 system. To install EPEL repo we will submit command line :
$ sudo dnf install epel-release
2. Enable pgAdmin Repository
On this stage, we will enable pgAdmin repository by donwloading its file pgAdmin source from official PostgreSQL web site. To download the source, we will use wget command line tools as shown below :
$ sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
3. Install pgAdmin on CentOS 8
After all are set, then we will install pgAdmin on CentOS by using command line :
$ sudo dnf -qy module disable postgresql $ sudo dnf install pgadmin4
Output :
[ramans@localhost ~]$ sudo dnf -qy module disable postgresql
[sudo] password for ramans:
[ramans@localhost ~]$ sudo dnf install pgadmin4
After installation was completed done, then we will bring the web server service up, on this tutorial we are using nginx as web server. To start and check Apache service we will use th following command line :
$ sudo systemctl start httpd $ sudo systemctl status nginx
Output :
[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 Feb 01 06:55:43 localhost systemd[1]: Starting The Apache HTTP Server... Feb 01 06:55:43 localhost httpd[5205]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using > Feb 01 06:55:43 localhost systemd[1]: Started The Apache HTTP Server. Feb 01 06:55:43 localhost httpd[5205]: Server configured, listening on: port 80
4. Configuring pgAdmin 4
On this stage, we will configure pgAdmin on our CentOS 8 environment. To configure pgAdmin we will modify pgAdmin configuration file which is provided /etc/httpd/conf.d/pgadmin4.conf.sample. We will make a copy and modify it according to the needs of our environment.
[ramans@localhost ~]$ sudo cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf [ramans@localhost ~]$ sudo vi /etc/httpd/conf.d/pgadmin4.conf
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>
Then we have to restart our Web server again by submitting command line :
$ sudo systemctl restart httpd
Then we will create a new two file for holding log file.
sudo mkdir -p /var/lib/pgadmin4/ /var/log/pgadmin4/
4.1 Modify Configurable Python Script
The pgadmin4 installation is accompanied with a configurable script to configure the pgAdmin web service, which will create a user account used to authenticate in the web interface, configure SELinux policies and Apache webserver to deploy pgAdmin web service.
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 mkdir -p /var/lib/pgadmin4/ /var/log/pgadmin4/ [ramans@localhost ~]$ sudo vi /usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py
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' ~
$ sudo dnf -y install python3-bcrypt python3-pynacl
Output :
[ramans@localhost ~]$ sudo dnf -y install python3-bcrypt python3-pynacl Last metadata expiration check: 0:27:39 ago on Mon 01 Feb 2021 06:35:02 AM PST. Package python3-bcrypt-3.1.6-2.el8.1.x86_64 is already installed. Package python3-pynacl-1.3.0-5.el8.x86_64 is already installed. Dependencies resolved. Nothing to do. Complete!
$ sudo python3 /usr/lib/python3.6/site-packages/pgadmin4-web/setup.py
Output :
[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:
4.2 pgAdmin Application Initialisation
On this stage we will initialize pgAdmin web page, by submitting the following command lines :
$ sudo chown -R apache:apache /var/lib/pgadmin4 /var/log/pgadmin4 $ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/lib/pgadmin4(/.*)?" $ sudo restorecon -Rv /var/lib/pgadmin4/ $ sudo restorecon -Rv /var/log/pgadmin4/
Output :
[ramans@localhost ~]$ sudo chown -R apache:apache /var/lib/pgadmin4 /var/log/pgadmin4
[ramans@localhost ~]$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/log/pgadmin4(/.*)?"
[ramans@localhost ~]$ sudo restorecon -Rv /var/lib/pgadmin4/
5. Accessing pgAdmin Web Interface
after all the installation steps are passed, then we can try to access pgAdmin web with a browser. The URL will be available at http://<ip_address_or_localhost>/pgadmin4.


Conlusion
On this short tutorial, we have learn how to install pgAdmin 4.30 on CentOS 8 opearating system successfully. I hope this tutorial will be useful.