pgAdmin 4 is a powerful web-based tool for managing PostgreSQL databases. This guide provides step-by-step instructions for installing and configuring pgAdmin 4 on Ubuntu (version 22.04 and later) and Debian 11/12.
Prerequisites
pgAdmin requires a web server like Apache.
1. Update the system
Update package lists:
apt update
2. Add the pgAdmin repository key
Run this command to add the repository key:
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | apt-key add
3. Add the pgAdmin repository
Add the pgAdmin repository by running the following command:
sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
4. Install pgAdmin 4
Now you can install pgAdmin 4:
apt install pgadmin4 -y
5. Run the pgAdmin 4 setup script
Nest run the pgAdmin 4 installation script:
/usr/pgadmin4/bin/setup-web.sh
6. Open Ports 80 and 443
To allow web traffic to pgAdmin, open the necessary ports based on your firewall setup.
Using IPtables
If you use IPtables, run:
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
To save the changes, install iptables-persistent (if not installed):
apt install iptables-persistent -y
Then save the rules:
iptables-save | tee /etc/iptables/rules.v4
Using UFW
If you use UFW (Uncomplicated Firewall), run:
ufw allow 'Apache Full'
Reload UFW:
ufw reload
7. Access pgAdmin 4
Once installed, access pgAdmin 4 via:
http://SERVER_IP/pgadmin4
Replace SERVER_IP with your server's actual IP address.
On the Login page, enter the email address and password you set during the installation process.
After logging in, you will see the pgAdmin dashboard. Now you can start working with pgAdmin: