Install phpPgAdmin or pgAdmin 4 on AlmaLinux 9 and Rocky Linux 9
Set up a web interface for PostgreSQL on AlmaLinux 9 or Rocky Linux 9: pgAdmin 4 from its official repository, or the maintained phpPgAdmin fork.
This guide gives you a browser-based administration tool for PostgreSQL on AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9. Older tutorials on this topic installed phpPgAdmin on CentOS 7, which reached end of life on 30 June 2024 and no longer receives security updates; the RHEL 9 family replaces it. The software has changed too: the original phpPgAdmin project has not published a release since 2020, so the main path below uses pgAdmin 4, the actively developed tool from the PostgreSQL community. If you specifically want the phpPgAdmin interface, the last section shows how to run its maintained community fork.
Is phpPgAdmin still maintained?
Only partly. The original repository's last release is 7.13.0 from November 2020. Its release notes list support for PostgreSQL 13 and "provisional" support for PostgreSQL 14, and say it was the last release to support PHP 7.2. Nothing newer has been tagged there, and the package in EPEL only ever existed for EL7.
A community fork continues the 7.14 line with fixes for current PHP versions and SCRAM-SHA-256 password support; that fork is what Debian 13 and Ubuntu 24.04 and 26.04 ship as the phppgadmin package. There is no package for the RHEL 9 family, so on these systems you either install the fork by hand or use pgAdmin 4, which has an official RPM repository and tracks new PostgreSQL releases.
Requirements
- A server running AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9 (x86_64; the pgAdmin RPM repository lists only that architecture).
- A non-root user with
sudorights. The examples usedeployon a server at203.0.113.10. - SELinux can stay in enforcing mode. The pgAdmin setup script sets the booleans and file contexts it needs.
Step 1: Install PostgreSQL
Skip this step if PostgreSQL is already running. The RHEL 9 family ships PostgreSQL 13 by default and newer versions as module streams. List what your release offers, then enable a stream; 16 is used here:
sudo dnf module list postgresql
sudo dnf module enable -y postgresql:16
sudo dnf install -y postgresql-server
The package does not create a database cluster or start the service on its own. Initialise it and enable the service:
sudo postgresql-setup --initdb
sudo systemctl enable --now postgresql
Step 2: Create a login role and allow password authentication
Do not use the postgres superuser from a web tool. Create a separate role with a password:
sudo -u postgres psql
CREATE ROLE dbadmin WITH LOGIN CREATEDB CREATEROLE PASSWORD 'choose-a-strong-password';
\q
pgAdmin connects over TCP to 127.0.0.1, so the local TCP rules in pg_hba.conf must accept passwords. Open the file:
sudo vi /var/lib/pgsql/data/pg_hba.conf
Find the two host lines for 127.0.0.1/32 and ::1/128. If their last column is ident, change it so the lines read:
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256
Reload PostgreSQL and test the login:
sudo systemctl reload postgresql
psql -h 127.0.0.1 -U dbadmin -d postgres -c 'select version();'
You do not need to open port 5432 in the firewall. The web tool runs on the same machine and talks to PostgreSQL locally.
Step 3: Install pgAdmin 4 in web mode
Add the pgAdmin repository package for the Red Hat family, then install the web-only package. It pulls in Apache (httpd) and the WSGI module.
sudo rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm
sudo dnf install -y pgadmin4-web
Run the setup script. It asks for an email address and password for the first pgAdmin account, creates the configuration database, sets the SELinux booleans and contexts, and offers to enable and start Apache:
sudo /usr/pgadmin4/bin/setup-web.sh
When it finishes, pgAdmin is served by Apache under the path /pgadmin4.
Step 4: Reach pgAdmin securely
A fresh install answers over plain HTTP, so do not expose it to the internet as it is. The simplest safe option is an SSH tunnel, which needs no firewall change. Run this on your own computer:
ssh -L 8080:127.0.0.1:80 deploy@203.0.113.10
Then open http://127.0.0.1:8080/pgadmin4 in your browser and sign in with the email address and password you gave the setup script.
If several people need access, put TLS in front of it instead: install mod_ssl, configure a certificate for a name such as db.example.com, and open only HTTPS:
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 5: Register your PostgreSQL server
In pgAdmin choose Add New Server. On the General tab give it any name. On the Connection tab enter:
- Host name/address:
127.0.0.1 - Port:
5432 - Maintenance database:
postgres - Username:
dbadminand the password from step 2
Save, and the server appears in the tree on the left with its databases, roles and a query tool.
Optional: install the phpPgAdmin fork instead
If you prefer the lighter PHP interface, install the community fork manually. It needs PHP 7.4 or newer with the PostgreSQL and mbstring extensions. The steps below use Apache with PHP-FPM from AppStream; check dnf module list php for the streams on your release.
sudo dnf module enable -y php:8.3
sudo dnf install -y httpd php php-pgsql php-mbstring tar
sudo mkdir /var/www/html/phppgadmin
curl -L https://github.com/ReimuHakurei/phpPgAdmin/archive/refs/tags/v7.14.8-mod.tar.gz | sudo tar -xz --strip-components=1 -C /var/www/html/phppgadmin
sudo cp /var/www/html/phppgadmin/conf/config.inc.php-dist /var/www/html/phppgadmin/conf/config.inc.php
Edit /var/www/html/phppgadmin/conf/config.inc.php and set the server host so that connections go over TCP:
$conf['servers'][0]['host'] = '127.0.0.1';
Leave $conf['extra_login_security'] set to true; it blocks logins as postgres and logins without a password. Allow the web server to reach the database under SELinux and start the services:
sudo setsebool -P httpd_can_network_connect_db 1
sudo systemctl enable --now php-fpm httpd
Use the same SSH tunnel as above and open http://127.0.0.1:8080/phppgadmin/. Check the fork's releases page for a newer tag before you copy the download URL.
Maintenance and troubleshooting
- Updates:
sudo dnf upgradeupdates PostgreSQL within its stream and pgAdmin from its repository. A manually installed phpPgAdmin is not updated bydnf; replace its files yourself when the fork publishes a release. - "Ident authentication failed": the
hostlines inpg_hba.confstill useident. Fix them as in step 2 and reload PostgreSQL. - pgAdmin page does not load: check
sudo systemctl status httpdand the logs under/var/log/pgadminand/var/log/httpd. - Old pgAdmin repository present: remove it first with
sudo rpm -e pgadmin4-redhat-repo, then install the current repository package.
Frequently asked questions
Can I still run phpPgAdmin on CentOS 7?
The EPEL 7 package still exists in archives, but it is an old 5.x build on an operating system without security updates. Move the database to a supported release and use pgAdmin 4 or the maintained fork there.
Does pgAdmin 4 need PHP?
No. pgAdmin 4 is a Python application that the RPM installs with its own virtual environment under /usr/pgadmin4 and runs through Apache's WSGI module. You do not need PHP on the server unless you choose phpPgAdmin.
Should I open port 5432 so the tool can connect?
No. Both tools run on the database server and connect to 127.0.0.1. Opening 5432 is only needed when other machines must connect to PostgreSQL directly, and then you should limit it to specific source addresses.
Can pgAdmin on this server manage databases on other hosts?
Yes. Register each one as an additional server in pgAdmin. The remote PostgreSQL instance must listen on a reachable address and have a pg_hba.conf rule for this server's IP.