How To Install pgAdmin 4 on CentOS 8 | RHEL 8

Posted on 50 views

PostgreSQL a popular powerful, and open source object-relational database system with more than 15 years of active development and strong reputation for reliability. pgAdmin is the leading Open Source feature-rich PostgreSQL administration and development platform that runs on Linux, Unix, Mac OS X, and Windows. This tutorial will show you how to install pgAdmin 4 on CentOS 8 Linux.

Features of pgAdmin 4 include:

  • auto-detection and support for objects discovered at run-time
  • a live SQL Query Tool with direct data editing
  • support for administrative queries
  • a syntax-highlighting SQL editor
  • redesigned graphical interfaces
  • powerful management dialogs and tools for common tasks
  • responsive, context-sensitive behavior
  • supportive error messages
  • helpful hints
  • online help and information about using pgAdmin dialogs and tools.

Step 1: Install PostgreSQL database server

You need to have PostgreSQL installed on your system before you can install pgAdmin 4. Below are the guides to help you install PostgreSQL:

Step 2: Add pgAdmin 4 repository

After installing PostgreSQL, you can begin the installation of pgAdmin 4 on CentOS 8|RHEL 8. You need to add pgAdmin 4 RPM:

sudo yum install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm

Successful installation message:

.....
Total size: 6.6 k
Installed size: 4.0 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pgadmin4-redhat-repo-2-1.noarch                                                                                                                                                    1/1
  Verifying  : pgadmin4-redhat-repo-2-1.noarch                                                                                                                                                    1/1

Installed:
  pgadmin4-redhat-repo-2-1.noarch

Complete!

You can check the contents of the repository file created using the following command:

$ cat /etc/yum.repos.d/pgadmin4.repo
[pgAdmin4]
name=pgadmin4
baseurl=https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/redhat/rhel-$releasever-$basearch
enabled=1
repo_gpgcheck=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGADMIN_PKG_KEY

Step 3: Install pgAdmin4 on CentOS 8|RHEL 8 Linux

There are there modes of installation:

  • Web mode
  • Desktop mode
  • Web & Desktop mode

To install for web mode only, suitable for server, use the commands::

sudo yum install pgadmin4-web

For desktop mode only, this is fit for Desktop Environment:

sudo yum install pgadmin4-desktop

Install for both desktop and web modes, if you need both:

sudo yum install pgadmin4

Review installation dependency tree then proceed:

....
Dependencies resolved.
================================================================================================================================================================================================
 Package                                      Architecture                      Version                                                              Repository                            Size
================================================================================================================================================================================================
Installing:
 pgadmin4-web                                 noarch                            6.8-1.el8                                                            pgAdmin4                             8.7 k
Installing dependencies:
 apr                                          x86_64                            1.6.3-12.el8                                                         appstream                            128 k
 apr-util                                     x86_64                            1.6.1-6.el8.1                                                        appstream                            104 k
 httpd                                        x86_64                            2.4.37-43.module+el8.5.0+747+83fae388.3                              appstream                            1.4 M
 httpd-filesystem                             noarch                            2.4.37-43.module+el8.5.0+747+83fae388.3                              appstream                             39 k
 httpd-tools                                  x86_64                            2.4.37-43.module+el8.5.0+747+83fae388.3                              appstream                            106 k
 mod_http2                                    x86_64                            1.15.7-3.module+el8.5.0+695+1fa8055e                                 appstream                            153 k
 pgadmin4-server                              x86_64                            6.8-1.el8                                                            pgAdmin4                              94 M
 python3-mod_wsgi                             x86_64                            4.6.4-4.el8                                                          appstream                            2.5 M
 rocky-logos-httpd                            noarch                            85.0-3.el8                                                           baseos                                22 k
Installing weak dependencies:
 apr-util-bdb                                 x86_64                            1.6.1-6.el8.1                                                        appstream                             23 k
 apr-util-openssl                             x86_64                            1.6.1-6.el8.1                                                        appstream                             26 k
Enabling module streams:
 httpd                                                                          2.4

Transaction Summary
================================================================================================================================================================================================
Install  12 Packages

Total download size: 98 M
Installed size: 267 M
Is this ok [y/N]: y

Step 4: Configure pgAdmin 4 on CentOS 7 / Fedora

Now that we have pgAdmin 4 installed, let’s configure it.

Start and enable httpd service to start on boot

sudo systemctl start httpd && sudo systemctl enable httpd

You can confirm service status by running:

$ 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 Sun 2021-10-24 22:34:22 UTC; 10s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 6377 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─6377 /usr/sbin/httpd -DFOREGROUND
           ├─6378 /usr/sbin/httpd -DFOREGROUND
           ├─6379 /usr/sbin/httpd -DFOREGROUND
           ├─6380 /usr/sbin/httpd -DFOREGROUND
           ├─6381 /usr/sbin/httpd -DFOREGROUND
           ├─6382 /usr/sbin/httpd -DFOREGROUND
           └─6383 /usr/sbin/httpd -DFOREGROUND

Oct 24 22:34:22 centos.hirebestengineers.com systemd[1]: Starting The Apache HTTP Server...
Oct 24 22:34:22 centos.hirebestengineers.com httpd[6377]: [Sun Oct 24 22:34:22.727756 2021] [so:warn] [pid 6377] AH01574: module wsgi_module is already loaded, skipping
Oct 24 22:34:22 centos.hirebestengineers.com systemd[1]: Started The Apache HTTP Server.

Finally, if you have installed pgadmin4 or pgadmin4-web, run the web setup script to configure the system to run in web mode:

sudo /usr/pgadmin4/bin/setup-web.sh

This will require you to input pgadmin4 user email address and set the password:

Setting up pgAdmin 4 in web mode on a Redhat based platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.

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

Email address: 
Password: 
Retype password: 
pgAdmin 4 - Application Initialisation
======================================

Creating storage and log directories...

Agree for the configuration of Apache Web server.

Configuring SELinux...
The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Continue (y/n)? y
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Apache successfully enabled.
Apache successfully started.
You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4

Step 5: Access pgAdmin 4 Web Interface

if you have an active firewall service, allow http port:

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

Open http://servername_or_ip/pgadmin4 to log in to the pgAdmin with the credentials created step 6 above.

pgAdmin-centos-7-fedora-29-login-1024x623

On the first page of pgAdmin, add a PostgreSQL server to administer with pgAdmin by clicking on “Add New Server”. This can be local or a remote PostgreSQL server.

pgAdmin-centos-7-fedora-29-add-server-01-1024x202

Under the “General” section, give the server a name & description.

pgAdmin-centos-7-fedora-29-addd-server-02-1024x777

Under “Connection” tab, provide access details – DB host, DB user and Password.

pgAdmin-centos-7-fedora-29-add-server-03-1013x1024

When done, Click Save button to save the configurations. If you were successful adding the server, the name will appear in the left sidebar. Select the server to see database summary information and make changes.

pgAdmin-centos-7-fedora-29-dashboard-1024x444

I hope our article was helpful in installing pgAdmin 4 on CentOS 8.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.