In this tutorial guide, I will be taking through the installation of pgAdmin 4 version 6.2 on Ubuntu 21.10.
pgAdmin 4 is a free and open-source management tool for Postgres. Its desktop runtime written in NWjs allows it to run standalone for individual users, or the web applications code may be directly deployed on a web server for use by the web browser.
pgAdmin 4 is a complete rewrite of pgAdmin, built using Python and Java
New features of pgAdmin 4 version 6.2
The following new features were introduced for the latest release of 6.2. these features are mostly for bug fixes.
- It added support of Aggregate and Operator node in view-only mode
- It ensures that users will be able to modify the REMOTE_USER environment variable as per their environment by introducing the new config parameter WEBSERVER_REMOTE_USER.
You can refer to pgAdmin 4 documentation for more concerning the bug fixes introduced with the current version 6.2.
Related Articles
Prerequisites
- Have PostgreSQL server running on Ubuntu 21.10
- Ubuntu 21.10 desktop
- User with sudo privileges
- Access to internet.
Table of Contents
- Update Ubuntu 21.10 repositories
- Install PostgreSQL server
- Install public key for the repository
- Create repository configuration files
- Install pgAdmin 4
- Configure web server
- Conclusion
1. Run Ubuntu 20.04 updates
In order to begin our installation, we will first update our repositories in order to make it up to date. on your terminal run the following commands;
$ sudo apt update
$ sudo apt upgrade -y
The commands above will update the system and upgrade packages accordingly.
2. Install PostgreSQL 14 server
To install PostgreSQL 14 server, follow the following steps;
create a file repository
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
After you have added the following script, now you can add GPG key.
Import GPG Key
Import GPG key pair in order to for it to be signed correctly. Use the following command to import the key.
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
You will get an ok as output meaning you have successfully added the GPG key.
Next we will run the updates so that
$ sudo apt update
Now we can install the latest version of PostgreSQL
Install PostgrSQL 14 on Ubuntu 21.10
Use the following command to install a specific version of PostgreSQL
$ sudo apt install postgresql-14 -y
Sample output will be as follows
...
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /lib/systemd/system/postgresql.service.
Setting up postgresql-14 (14.1-1.pgdg21.10+1) ...
Creating new PostgreSQL cluster 14/main ...
/usr/lib/postgresql/14/bin/initdb -D /var/lib/postgresql/14/main --auth-local peer --auth-host scram-sha-256 --no-instructions
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
We have successfully installed PostgreSQL. We can proceed to install pgAdmin 4.
3. Install public key for pgAdmin 4 repository
Use the following command to add public key to your repository.
$ sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
You will see the following output
....
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
100 3935 100 3935 0 0 11472 0 --:--:-- --:--:-- --:--:-- 11438
OK
4. Create pgAdmin 4 repository file
Then we can go ahead and create a configuration repository file.
$ 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'
Update your system now for the changes to take effect before installing the pgAdmin 4.
5. Install pgAdmin 4 version 6.2
We will install pgAdmin 4 for both web and desktop environments.
$ sudo apt install pgadmin4
Sample output from the installation
...
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-htcacheclean.service.
Setting up libxaw7:amd64 (2:1.0.13-1.1) ...
Setting up libapache2-mod-wsgi-py3 (4.7.1-3build2) ...
apache2_invoke: Enable module wsgi
Setting up x11-xserver-utils (7.7+8build1) ...
Setting up x11-utils (7.7+5build1) ...
Setting up pgadmin4-web (6.2) ...
Setting up pgadmin4 (6.2) ...
Setting up liblwp-protocol-https-perl (6.10-1) ...
Setting up libwww-perl (6.53-1) ...
Setting up libxml-parser-perl:amd64 (2.46-2) ...
Setting up libxml-twig-perl (1:3.52-1) ...
Setting up libnet-dbus-perl (1.2.0-1build1) ...
Processing triggers for ufw (0.36.1-1ubuntu1) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.34-0ubuntu3) ...
Scanning processes...
Scanning candidates...
Scanning linux images...
Having completed the installation of pgAdmin 4 we now need to connect with our Apache web server
6. Configure Apache for pgAdmin 4
Let’s serve our pgAdmin 4 using Apache webserver.
To do so we need to initiate Apache webserver configuration with the following script.
$ sudo /usr/pgadmin4/bin/setup-web.sh
You will need to configure the email address and password to continue using.
The following is the output you will get.
...
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:
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
To access pgadmin 4 from the browser go to this web address http://<your_server_IP>/pgadmin4
Use the credentials you set above to login
7. Conclusion
We have successfully installed pgAdmin 4 in our system. Go ahead and experiment more to gain more insight.