Updated: 18 November 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
CentOS 7 reached end of life on 30 June 2024, so this guide now uses AlmaLinux 9 / Rocky Linux 9 (the steps also suit other RHEL 9 rebuilds).
phpMyAdmin manages MySQL/MariaDB in a browser. Because it is a common target for attacks, install it with extra protection.
Before you start
- A VPS or dedicated server with a fresh Ubuntu 24.04 / Debian 12 or AlmaLinux 9 / Rocky Linux 9 installation, and root or sudo access.
- A domain or subdomain pointing to the server (an A record), if you want HTTPS.
- The system updated:
apt update && apt upgradeordnf upgrade.
Install
apt install phpmyadmin # Ubuntu / Debian (choose apache2 when asked) dnf install epel-release && dnf install phpMyAdmin # AlmaLinux / Rocky
Secure it
- Serve it over HTTPS only (see the certificate step below).
- Allow only your IP address. On AlmaLinux/Rocky edit
/etc/httpd/conf.d/phpMyAdmin.confand setRequire ip 203.0.113.10; on Ubuntu add a<Directory /usr/share/phpmyadmin>block with the same rule. - Add a second password prompt with HTTP basic authentication, or change the URL alias from
/phpmyadminto something less obvious. - Log in with a normal database user, not root.
Reload Apache after changes.
Add a free SSL certificate
apt install certbot python3-certbot-apache # Ubuntu / Debian dnf install epel-release && dnf install certbot python3-certbot-apache # AlmaLinux / Rocky certbot --apache -d example.com -d www.example.com
Certbot installs a timer that renews the certificate automatically; test it with certbot renew --dry-run.