sudo apt install phpmyadmin, select no web server when asked, link /usr/share/phpmyadmin into your site’s web root under a hard-to-guess path, add an Nginx location block that passes PHP to PHP-FPM, protect it with a second password, and log in with a dedicated database user rather than root.
Before you start
- You need a working Nginx + PHP-FPM + MariaDB setup. See install a LEMP stack.
- Use HTTPS, so your database password is never sent in plain text. See get a free SSL certificate with Certbot.
- phpMyAdmin is a web page for managing MySQL and MariaDB databases in your browser. Because it is public, bots look for it. The steps below hide and lock it down.
How to install phpMyAdmin
1
Install the packages
2
Choose no web server
At Web server to reconfigure automatically, the choices are
apache2 and lighttpd. Select neither: make sure no box has a *, then press Tab to reach Ok and press Enter.3
Answer the database question
At Configure database for phpmyadmin with dbconfig-common? choose No for a simple setup. phpMyAdmin works without it; choosing Yes creates an extra
phpmyadmin database for optional features such as bookmarks. You can change this later with sudo dpkg-reconfigure phpmyadmin./usr/share/phpmyadmin and the configuration in /etc/phpmyadmin, as the phpMyAdmin documentation notes for Debian and Ubuntu packages.
How to set up phpMyAdmin in Nginx
1
Link phpMyAdmin into your web root
Pick a path that is not easy to guess. This example uses
dbadmin-7f3k and the default web root /var/www/html:2
Create a login for the password prompt
-c when adding more users later.3
Add a location block
Open your site’s server block, for example Use the PHP-FPM socket for your PHP version:
/etc/nginx/sites-available/default, and add inside the server { … } block:php8.3-fpm.sock on Ubuntu 24.04 and php8.2-fpm.sock on Debian 12. Run ls /run/php/ to see yours. The deny rule blocks phpMyAdmin’s internal folders, as the phpMyAdmin documentation recommends.4
Test and reload Nginx
nginx -t must say syntax is ok and test is successful before you reload.How to create a database user for phpMyAdmin
On Ubuntu and Debian, the databaseroot user logs in through the Linux socket, so phpMyAdmin cannot sign in as root. You see Access denied for user 'root'@'localhost'. Create an admin user instead:
How to check it worked
- Open
https://example.com/dbadmin-7f3k/in your browser. - Enter the Nginx login you made with
htpasswd. - On the phpMyAdmin page, log in with
pmaadminand its password.
How to lock phpMyAdmin down further
Frequently asked questions
Why do I get 502 Bad Gateway?
Nginx cannot reach PHP-FPM. Check that the socket path infastcgi_pass matches a file in /run/php/ and that PHP-FPM is running. See fix 502 Bad Gateway in Nginx.
Why does my browser download index.php instead of opening it?
Thelocation ~ \.php$ block is missing or outside the phpMyAdmin block, so Nginx sends the file as-is. Check the block and reload Nginx.
Can I use phpMyAdmin with Apache instead?
Yes. Chooseapache2 at the web server question and the package configures it for you. See install Apache.
Is phpMyAdmin included on FREAKHOSTING panels?
The Game Panel and Web Panel already have phpMyAdmin built in. See Game Panel databases and Web Panel databases. This guide is for your own VPS or dedicated server.Related guides
VPS and dedicated server guides
Every guide in this section.
Install a LEMP stack
Nginx, PHP and MariaDB first.
Secure MySQL and MariaDB
Harden the database itself.
Set up Nginx server blocks
Where the location block goes.
Connect with HeidiSQL
A desktop alternative over SSH.
Checked against the official phpMyAdmin documentation and nginx documentation on 4 November 2026; package install, Nginx config (
nginx -t), password prompt, folder blocking and database login tested on Ubuntu 24.04 LTS with phpMyAdmin 5.2.1, Nginx 1.24, PHP 8.3 and MariaDB 10.11. Commands can differ on other distributions or releases.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026