In this short tutorial, we will learn how to install pgAdmin 4 on Ubuntu 22.04 LTS operating system. pgAdmin is used to manage PostgreSQL database which can help developers or DBA in doing his job. pgAdmin is written in Python and jQuery, it supports all the features found in PostgreSQL. We can use pgAdmin to do everything from writing basic SQL queries to monitoring our databases and configuring advanced database architectures.
pgAdmin offers two types of installation one is Desktop Deployment and other Server Deployment. In this tutorial, we’ll learn the process of installing and configuring the pgAdmin 4 on an Ubuntu 22.04 server, accessing pgAdmin through a web browser, and connecting it to a PostgreSQL database on our server.
pgAdmin 4 Installation on Ubuntu 22.04
Prerequisites
Before starting the installation of pgAdmin 4, we must prepare an environment that supports the installation process, as mentioned below :
- A server running Ubuntu 22.04.
- A non-root user with sudo privileges.
- PostgreSQL database installed on the server.
pgAdmin 4 installation will be consist of several steps, namely :
- Add the public key for the repository
- Create the repository configuration file
- Updating Ubuntu 22.04
- Installing pgAdmin4 on Ubuntu 22.04 server
- Configuring the pgAdmin user account
- Accessing pgAdmin 4 Web Interface
1. Add the public key for the repository
The first step is to install pgAdmin 4 public key for the repository. For this purpose we will submit the command line :
$ curl -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pgadmin.gpg
2. Create the repository configuration file
Since pgAdmin is not Ubuntu’s default system repository, then we manually need to add the officially issued repo by the developers of this tool, by submitting command line:
$ sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list'
3. Updating Ubuntu 22.04
In this step we will update our local packages repository, this task is to make sure if we are accessing the latest packages versions. To perfrom this task, we will use command line :
$ sudo apt update
Output :
ramans@infodiginet:~$ sudo apt update Hit:1 http://id.archive.ubuntu.com/ubuntu jammy InRelease Hit:2 http://id.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease Hit:4 http://id.archive.ubuntu.com/ubuntu jammy-backports InRelease Hit:5 http://apt.postgresql.org/pub/repos/apt jammy-pgdg InRelease Hit:6 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4 InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done
4. Installing pgAdmin4 on Ubuntu 22.04 Server
There are 3 ways to install pgAdmin to choose from, namely:
- pgAdmin can be used as a desktop application
sudo apt install pgadmin4-desktop
- pgAdmin as a web application
sudo apt install pgadmin4-web
- both or any one of the two
sudo apt install pgadmin4
In our scenario, we will install pgAdmin 4 on Ubuntu 22.04 server as well as pgAdmin as desktop application. We will use command line :
$ sudo apt install pgadmin4
Output :
ramans@infodiginet:~$ sudo apt install pgadmin4 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: libflashrom1 libftdi1-2 Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-wsgi-py3 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap pgadmin4-desktop pgadmin4-server pgadmin4-web Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-wsgi-py3 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap pgadmin4 pgadmin4-desktop pgadmin4-server pgadmin4-web 0 upgraded, 13 newly installed, 0 to remove and 4 not upgraded. Need to get 183 MB of archives. After this operation, 8.010 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 libapr1 amd64 1.7.0-8build1 [107 kB] Get:2 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 libaprutil1 amd64 1.6.1-5ubuntu4 [92,4 kB] Get:3 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-5ubuntu4 [11,3 kB] Get:4 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 libaprutil1-ldap amd64 1.6.1-5ubuntu4 [9.162 B] Get:5 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2-bin amd64 2.4.52-1ubuntu4.2 [1.344 kB] Get:6 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main amd64 pgadmin4-server amd64 6.17 [76,1 MB] Get:7 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2-data all 2.4.52-1ubuntu4.2 [165 kB] Get:8 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2-utils amd64 2.4.52-1ubuntu4.2 [89,3 kB] Get:9 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2 amd64 2.4.52-1ubuntu4.2 [97,9 kB] Get:10 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libapache2-mod-wsgi-py3 amd64 4.9.0-1ubuntu0.1 [106 kB] Ign:6 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main amd64 pgadmin4-server amd64 6.17 Get:11 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main amd64 pgadmin4-desktop amd64 6.17 [105 MB] Ign:11 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main amd64 pgadmin4-desktop amd64 6.17 Get:12 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main all pgadmin4-web all 6.17 [2.548 B] Get:13 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main all pgadmin4 all 6.17 [670 B] Get:6 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main amd64 pgadmin4-server amd64 6.17 [76,1 MB] Get:11 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4/main amd64 pgadmin4-desktop amd64 6.17 [105 MB] Fetched 172 MB in 17min 52s (161 kB/s) Selecting previously unselected package libapr1:amd64. (Reading database ... 198134 files and directories currently installed.) Preparing to unpack .../00-libapr1_1.7.0-8build1_amd64.deb ... Unpacking libapr1:amd64 (1.7.0-8build1) ... Selecting previously unselected package libaprutil1:amd64. Preparing to unpack .../01-libaprutil1_1.6.1-5ubuntu4_amd64.deb ... Unpacking libaprutil1:amd64 (1.6.1-5ubuntu4) ... Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64. Preparing to unpack .../02-libaprutil1-dbd-sqlite3_1.6.1-5ubuntu4_amd64.deb ... Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.1-5ubuntu4) ... Selecting previously unselected package libaprutil1-ldap:amd64. Preparing to unpack .../03-libaprutil1-ldap_1.6.1-5ubuntu4_amd64.deb ... Unpacking libaprutil1-ldap:amd64 (1.6.1-5ubuntu4) ... Selecting previously unselected package apache2-bin. Preparing to unpack .../04-apache2-bin_2.4.52-1ubuntu4.2_amd64.deb ... Unpacking apache2-bin (2.4.52-1ubuntu4.2) ... Selecting previously unselected package apache2-data. Preparing to unpack .../05-apache2-data_2.4.52-1ubuntu4.2_all.deb ... Unpacking apache2-data (2.4.52-1ubuntu4.2) ... Selecting previously unselected package apache2-utils. Preparing to unpack .../06-apache2-utils_2.4.52-1ubuntu4.2_amd64.deb ... Unpacking apache2-utils (2.4.52-1ubuntu4.2) ... Selecting previously unselected package apache2. Preparing to unpack .../07-apache2_2.4.52-1ubuntu4.2_amd64.deb ... Unpacking apache2 (2.4.52-1ubuntu4.2) ... Selecting previously unselected package libapache2-mod-wsgi-py3. Preparing to unpack .../08-libapache2-mod-wsgi-py3_4.9.0-1ubuntu0.1_amd64.deb ... Unpacking libapache2-mod-wsgi-py3 (4.9.0-1ubuntu0.1) ... Selecting previously unselected package pgadmin4-server. Preparing to unpack .../09-pgadmin4-server_6.17_amd64.deb ... Unpacking pgadmin4-server (6.17) ... Selecting previously unselected package pgadmin4-desktop. Preparing to unpack .../10-pgadmin4-desktop_6.17_amd64.deb ... Unpacking pgadmin4-desktop (6.17) ... Selecting previously unselected package pgadmin4-web. Preparing to unpack .../11-pgadmin4-web_6.17_all.deb ... Unpacking pgadmin4-web (6.17) ... Selecting previously unselected package pgadmin4. Preparing to unpack .../12-pgadmin4_6.17_all.deb ... Unpacking pgadmin4 (6.17) ... Setting up pgadmin4-server (6.17) ... Setting up libapr1:amd64 (1.7.0-8build1) ... Setting up pgadmin4-desktop (6.17) ... Setting up apache2-data (2.4.52-1ubuntu4.2) ... Setting up libaprutil1:amd64 (1.6.1-5ubuntu4) ... Setting up libaprutil1-ldap:amd64 (1.6.1-5ubuntu4) ... Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.1-5ubuntu4) ... Setting up apache2-utils (2.4.52-1ubuntu4.2) ... Setting up apache2-bin (2.4.52-1ubuntu4.2) ... Setting up apache2 (2.4.52-1ubuntu4.2) ... Enabling module mpm_event. Enabling module authz_core. Enabling module authz_host. Enabling module authn_core. Enabling module auth_basic. Enabling module access_compat. Enabling module authn_file. Enabling module authz_user. Enabling module alias. Enabling module dir. Enabling module autoindex. Enabling module env. Enabling module mime. Enabling module negotiation. Enabling module setenvif. Enabling module filter. Enabling module deflate. Enabling module status. Enabling module reqtimeout. Enabling conf charset. Enabling conf localized-error-pages. Enabling conf other-vhosts-access-log. Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service. Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclea n.service. Setting up libapache2-mod-wsgi-py3 (4.9.0-1ubuntu0.1) ... apache2_invoke: Enable module wsgi Setting up pgadmin4-web (6.17) ... Setting up pgadmin4 (6.17) ... Processing triggers for mailcap (3.70+nmu1ubuntu1) ... Processing triggers for desktop-file-utils (0.26-1ubuntu3) ... Processing triggers for hicolor-icon-theme (0.17-2) ... Processing triggers for gnome-menus (3.36.0-1ubuntu3) ... Processing triggers for libc-bin (2.35-0ubuntu3.1) ... Processing triggers for ufw (0.36.1-4build1) ... Processing triggers for man-db (2.10.2-1) ...
We will verify, if pgAdmin 4 installation has completed done successfully by submitting command line :
$ systemctl status apache2
Output :
ramans@infodiginet:~$ systemctl status apache2 ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2022-12-13 13:37:44 WIB; 31min ago Docs: https://httpd.apache.org/docs/2.4/ Process: 9746 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 9750 (apache2) Tasks: 55 (limit: 4584) Memory: 14.7M CPU: 231ms CGroup: /system.slice/apache2.service ├─9750 /usr/sbin/apache2 -k start ├─9751 /usr/sbin/apache2 -k start └─9752 /usr/sbin/apache2 -k start Des 13 13:37:44 infodiginet systemd[1]: Starting The Apache HTTP Server... Des 13 13:37:44 infodiginet apachectl[9749]: AH00558: apache2: Could not reliably determine the server's fully qualified domain> Des 13 13:37:44 infodiginet systemd[1]: Started The Apache HTTP Server.

5. Configuring the pgAdmin user account
At this stage, we will configure a user who has access to use web GUI of pgAdmin. For this purpose we will submit the following script as previously prepared in the pgAdmin installation package. We will be prompted to supply email address and password.
$ sudo /usr/pgadmin4/bin/setup-web.sh
Output :
ramans@infodiginet:~$ sudo /usr/pgadmin4/bin/setup-web.sh [sudo] password for ramans: Setting up pgAdmin 4 in web mode on a Debian 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: ramansah@infodiginet.com Password: Retype password: pgAdmin 4 - Application Initialisation ====================================== Creating storage and log directories... We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? y The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4
6. Accessing pgAdmin 4 Web Interface
The pgAdmin 4 web interface can be accessed on URL : http://hostname_or_server_ip_address/pgadmin4
. In our tutorial, we will hit URL on https://infodiginet/pgadmin4 and supply the username (email address and password as we have created on step no. 5). as shown below.

after successfully logging in, we will be taken to the main menu like the screen shot below.

So far, we have reached the installation process of pgAdmin 4 on Ubuntu 22.04 server.
Conclusion
In this short tutorial, we have learned how to install pgAdmin 4 on Ubuntu 22.04 operating system. I hope this tutorial will be helpfull.