How to install pgAdmin 4 on CentOS 8 Linux

PostgreSQL is a popular, powerful and open source object-relational database system with over 15 years of active development experience and a reputation for reliability. pgAdmin is the leading open source feature-rich PostgreSQL management 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

Features of pgAdmin 4 include:

  • Automatically detect and support objects discovered at runtime
  • Real-time SQL query tool with direct data editing
  • Support management query
  • SQL editor with syntax highlighting
  • Redesigned graphical interface
  • Powerful management dialogs and common task tools
  • Responsive, context-sensitive behavior
  • Supporting error messages
  • Helpful tips
  • Online help and information on using pgAdmin dialogs and tools.

Step 1: Enable EPEL repository

Use the guide below to add an EPEL repository.

Enable EPEL on CentOS 8

Don’t forget to enable the PowerTools repository as it contains the packages we need.

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled PowerTools

Step 2: Install the PostgreSQL database server

You must have PostgreSQL installed on your system before you can install pgAdmin 4. Here are guidelines to help you install PostgreSQL:

How to install PostgreSQL 11 on CentOS 8

Install PostgreSQL 12 on CentOS 8

Step 3: Install pgAdmin4 on CentOS 8

After installing PostgreSQL, you can start the installation of pgAdmin 4 on CentOS 8. You need to add the PostgreSQL RPM repository, this should be done when installing PostgreSQL.

sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Then install the pgAdmin package:

sudo dnf install pgadmin4

By pressing “ÿ“key.

CentOS-8 - PowerTools                                                                                                    13 kB/s | 4.3 kB     00:00    
Dependencies resolved.
========================================================================================================================================================
 Package                                        Arch                Version                                               Repository               Size
========================================================================================================================================================
Installing:
 pgadmin4                                       x86_64              4.16-2.rhel8                                          pgdg10                   15 k
Installing dependencies:
 apr                                            x86_64              1.6.3-9.el8                                           AppStream               125 k
 apr-util                                       x86_64              1.6.1-6.el8                                           AppStream               105 k
 centos-logos-httpd                             noarch              80.5-2.el8                                            AppStream                24 k
 httpd                                          x86_64              2.4.37-12.module_el8.0.0+185+5908b0db                 AppStream               1.7 M
 httpd-filesystem                               noarch              2.4.37-12.module_el8.0.0+185+5908b0db                 AppStream                35 k
 httpd-tools                                    x86_64              2.4.37-12.module_el8.0.0+185+5908b0db                 AppStream               102 k
 mod_http2                                      x86_64              1.11.3-3.module_el8.0.0+185+5908b0db                  AppStream               158 k
 python3-click                                  noarch              6.7-8.el8                                             AppStream               131 k
 python3-flask                                  noarch              1:0.12.2-3.el8                                        AppStream               141 k
 python3-itsdangerous                           noarch              0.24-14.el8                                           AppStream                31 k
 python3-lxml                                   x86_64              4.2.3-1.el8                                           AppStream               1.5 M
 python3-mako                                   noarch              1.0.6-13.el8                                          AppStream               157 k
 python3-mod_wsgi                               x86_64              4.6.4-3.el8                                           AppStream               2.5 M
 python3-sqlalchemy                             x86_64              1.3.2-1.module_el8.0.0+33+0a10c0e1                    AppStream               1.9 M
 python3-webencodings                           noarch              0.5.1-6.el8                                           AppStream                27 k
 python3-werkzeug                               noarch              0.12.2-4.el8                                          AppStream               457 k
 python3-unittest2                              noarch              1.1.0-16.el8                                          PowerTools              186 k
 python3-alembic                                noarch              1.0.11-2.el8                                          epel                    787 k
 python3-beautifulsoup4                         noarch              4.6.3-2.el8.1                                         epel                    185 k
 python3-blinker                                noarch              1.4-4.el8                                             epel                    114 k
 python3-editor                                 noarch              1.0.4-1.el8                                           epel                     19 k
 pgadmin4-docs                                  noarch              4.16-2.rhel8                                          pgdg10                   39 M
 pgadmin4-python3-Flask-Mail                    noarch              0.9.1-4.rhel8.1                                       pgdg10                   24 k
 pgadmin4-python3-dateutil                      noarch              1:2.8.0-1.rhel8                                       pgdg10                  290 k
 pgadmin4-python3-flask                         noarch              1:1.0.2-1.rhel8                                       pgdg10                  153 k
 pgadmin4-python3-flask-babel                   noarch              0.11.1-4.rhel8.1                                      pgdg10                   54 k
 pgadmin4-python3-flask-babelex                 noarch              0.9.3-1.rhel8.1                                       pgdg10                   23 k
 pgadmin4-python3-flask-compress                noarch              1.4.0-1.rhel8                                         pgdg10                   15 k
 pgadmin4-python3-flask-gravatar                noarch              0.5.0-1.rhel8.1                                       pgdg10                   17 k
 pgadmin4-python3-flask-htmlmin                 noarch              1.5.0-1.rhel8                                         pgdg10                   14 k
 pgadmin4-python3-flask-login                   noarch              0.4.1-1.rhel8                                         pgdg10                   34 k
 pgadmin4-python3-flask-migrate                 noarch              2.4.0-1.rhel8                                         pgdg10                   28 k
 pgadmin4-python3-flask-paranoid                noarch              0.2-1.rhel8.1                                         pgdg10                   15 k
 pgadmin4-python3-flask-principal               noarch              0.4.0-14.rhel8.1                                      pgdg10                   20 k
 pgadmin4-python3-flask-security                noarch              3.0.0-1.rhel8.1                                       pgdg10                   82 k
 pgadmin4-python3-flask-sqlalchemy              noarch              2.3.2-1.rhel8.1                                       pgdg10                  109 k
 pgadmin4-python3-flask-wtf                     noarch              0.14.2-1.rhel8.1                                      pgdg10                   59 k
 pgadmin4-python3-htmlmin                       noarch              0.1.12-1.rhel8.1                                      pgdg10                   44 k
 pgadmin4-python3-paramiko                      noarch              2.6.0-3.rhel8                                         pgdg10                  288 k
 pgadmin4-python3-passlib                       noarch              1.7.1-1.rhel8.1                                       pgdg10                  745 k
 pgadmin4-python3-psutil                        x86_64              5.5.1-1.rhel8                                         pgdg10                  378 k
 pgadmin4-python3-simplejson                    x86_64              3.16.0-1.rhel8                                        pgdg10                  278 k
 pgadmin4-python3-six                           noarch              1.12.0-3.rhel8                                        pgdg10                   35 k
 pgadmin4-python3-speaklater                    noarch              1.3-3.rhel8.1                                         pgdg10                   15 k
 pgadmin4-python3-sqlalchemy                    x86_64              1.2.18-1.rhel8                                        pgdg10                  3.9 M
 pgadmin4-python3-sqlparse                      noarch              0.2.4-1.rhel8.1                                       pgdg10                   78 k
 pgadmin4-python3-sshtunnel                     noarch              0.1.4-1.rhel8                                         pgdg10                   45 k
 pgadmin4-python3-werkzeug                      noarch              0.15.4-1.rhel8                                        pgdg10                  464 k
 pgadmin4-python3-wtforms                       noarch              2.2.1-1.rhel8                                         pgdg10                  184 k
 pgadmin4-pytz                                  noarch              2018.9-1.rhel8                                        pgdg10                   53 k
 pgadmin4-web                                   noarch              4.16-2.rhel8                                          pgdg10                  4.9 M
 python3-psycopg2                               x86_64              2.8.3-2.rhel8                                         pgdg10                  175 k
Installing weak dependencies:
 apr-util-bdb                                   x86_64              1.6.1-6.el8                                           AppStream                25 k
 apr-util-openssl                               x86_64              1.6.1-6.el8                                           AppStream                27 k
 python3-html5lib                               noarch              1:0.999999999-6.el8                                   AppStream               214 k
 python3-cssselect                              noarch              0.9.2-10.el8                                          epel                     40 k
Enabling module streams:
 httpd                                                              2.4                                                                                

Transaction Summary
========================================================================================================================================================
Install  57 Packages

Total download size: 62 M
Installed size: 154 M
Is this ok [y/N]: y

Step 3: Configure pgAdmin 4 on CentOS 8

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

1. Start and enable the httpd service to start at startup:

sudo systemctl start httpd && sudo systemctl enable httpd

You can confirm the 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 Wed 2020-01-15 12:59:34 EAT; 6s ago
      Docs: man:httpd.service(8)
  Main PID: 3310 (httpd)
    Status: "Started, listening on: port 80"
     Tasks: 213 (limit: 11512)
    Memory: 36.6M
    CGroup: /system.slice/httpd.service
            ├─3310 /usr/sbin/httpd -DFOREGROUND
            ├─3311 /usr/sbin/httpd -DFOREGROUND
            ├─3312 /usr/sbin/httpd -DFOREGROUND
            ├─3313 /usr/sbin/httpd -DFOREGROUND
            └─3314 /usr/sbin/httpd -DFOREGROUND
 Jan 15 12:59:34 cent8.novalocal systemd[1]: Starting The Apache HTTP Server…
 Jan 15 12:59:34 cent8.novalocal httpd[3310]: Server configured, listening on: port 80
 Jan 15 12:59:34 cent8.novalocal systemd[1]: Started The Apache HTTP Server.

2. Rename pgAdmin Apache configuration example:

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

Confirm the configuration syntax to prevent any errors, and restart the httpd service.

$ sudo httpd -tSyntax OK$ sudo systemctl restart httpd

4. Create the pgAdmin data directory:

sudo mkdir -p /var/lib/pgadmin4/ /var/log/pgadmin4/

5. Edit config_local.py And add the following settings. In most cases, the default file location should be appropriate:

sudo vi /usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py

Add:

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'

6. Run the following command to create the configuration database:

sudo dnf -y install python3-bcrypt python3-pynacl
sudo python3 /usr/lib/python3.6/site-packages/pgadmin4-web/setup.py

This will ask you to enter email address with password Used for the initial pgAdmin user account.

Email address: [email protected]
Password: <INPUT PASSWORD>
Retype password:<Confirm PASSWORD>
pgAdmin 4 - Application Initialisation
======================================

Set the permissions of the pgAdmin directory to apache user:

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

Step 4: Configure SELinux

Set the permissions of the pgAdmin directory to apache user:

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

If you are running SELinux in force mode, create and apply a policy to allow Apache users to access the pgAdmin directory:

sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/lib/pgadmin4(/.*)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/log/pgadmin4(/.*)?"
sudo restorecon -Rv /var/lib/pgadmin4/
sudo restorecon -Rv /var/log/pgadmin4/

Restart the httpd service.

sudo systemctl restart httpd

Step 5: Access the pgAdmin 4 web interface

If you have an active firewall service, allow http ports:

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

turn on http://servername_or_ip/pgadmin4 Log in to pgAdmin with the credentials steps created 6 the above.

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

How to install pgAdmin 4 on CentOS 8 Linux

under “Fair” Section, give the server a name and description.

How to install pgAdmin 4 on CentOS 8 Linux

Down “Connect” The tab provides access details-database host, database user and password.

How to install pgAdmin 4 on CentOS 8 Linux

When done, click Save Button save
Configuration. If the server is successfully added, the name will be
Appears in the left sidebar. Select server to view database summary
Information and make changes.

How to install pgAdmin 4 on CentOS 8 Linux

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

Other guides on installing pgAdmin 4:

Install pgAdmin4 on CentOS 7 / Fedora

How to install pgAdmin4 on FreeBSD 12

Install pgAdmin4 on Ubuntu

Install pgAdmin4 on Debian

Sidebar