phpMyAdmin gives you a clean web interface for managing MySQL and MariaDB databases without touching the command line. If your server runs Nginx instead of Apache, the default phpMyAdmin installer tries to configure Apache for you, which causes confusion. This guide shows you the correct way to install phpMyAdmin on Ubuntu 24.04 with Nginx, PHP-FPM, and MySQL, end to end, including the fixes for the three most common errors.

By the end you will have phpMyAdmin running at http://your-server-ip/phpmyadmin, secured with a dedicated database user and HTTPS-ready configuration.

Prerequisites

  • Ubuntu 24.04 LTS server with a non-root user that has sudo privileges
  • Nginx installed and serving at least one site (root typically /var/www/html)
  • PHP 8.3 with PHP-FPM installed (php8.3-fpm)
  • MySQL 8.0 or MariaDB installed and running
  • A firewall allowing HTTP/HTTPS traffic

If you are starting from a bare server, install the LEMP stack first:

sudo apt update
sudo apt install -y nginx mysql-server php-fpm php-mysql

This installs Nginx, MySQL, and the PHP-FPM processor with the MySQL driver for PHP. Verify everything is running before continuing.

Step 1: Install phpMyAdmin from the Ubuntu repository

Ubuntu 24.04 ships phpMyAdmin 5.2 in its repositories, which supports PHP 8.3. Install it along with the PHP extensions phpMyAdmin needs:

sudo apt update
sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-xml php-curl

php-mbstring handles multibyte string functions, php-zip enables import/export of compressed dumps, php-gd powers CAPTCHA and image features, php-xml is needed for the XML export format, and php-curl supports update checks and external requests.

During installation you will see two prompts:

  1. Web server to configure automatically: press Space to deselect Apache (it is selected by default) and make sure neither Apache nor lighttpd is highlighted, then press Tab and Enter. We configure Nginx manually in the next steps, and letting the installer write an Apache config on an Nginx server only causes trouble.
  2. Configure database for phpmyadmin with dbconfig-common? select Yes. This creates phpMyAdmin's internal configuration-storage database. Enter a strong password for the phpmyadmin database user when asked and keep it somewhere safe.

Step 2: Link phpMyAdmin into your Nginx document root

The package installs phpMyAdmin's files to /usr/share/phpmyadmin. Since Nginx already serves PHP from your document root, the simplest reliable approach is a symlink:

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

This makes http://your-server-ip/phpmyadmin resolve to the phpMyAdmin files. Make sure your Nginx server block passes .php files to PHP-FPM (the default Ubuntu Nginx + PHP setup does). Check your site config:

sudo nano /etc/nginx/sites-available/default

Confirm the PHP block looks like this:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}

If you edited the file, test the syntax and reload Nginx:

sudo nginx -t
sudo systemctl reload nginx

nginx -t validates the configuration before applying it, so a typo can never take your site down.

Step 3: Create a dedicated MySQL user for phpMyAdmin

MySQL 8.0 on Ubuntu uses the auth_socket plugin for the root user, which means root can only log in from the system root account, not through phpMyAdmin's login form. Create a dedicated admin user instead. This is also much safer than exposing root over a web panel.

sudo mysql

Then run these statements, replacing the password with your own strong one:

CREATE USER 'pma_admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Your-Strong-Password-Here';
GRANT ALL PRIVILEGES ON *.* TO 'pma_admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

mysql_native_password keeps compatibility with PHP's MySQL driver, and FLUSH PRIVILEGES makes MySQL reload the grant tables immediately.

Step 4: Set the blowfish secret and temp directory

phpMyAdmin requires a 32-character secret for cookie-based authentication. Generate one and add it to the config:

openssl rand -base64 24

Copy the output, then open the configuration file:

sudo nano /etc/phpmyadmin/config.inc.php

Find the blowfish line and set your secret:

$cfg['blowfish_secret'] = 'paste-your-32-char-secret-here';

While you are in there, set the temp directory so imports and session files have a writable home:

$cfg['TempDir'] = '/usr/share/phpmyadmin/tmp/';

Then create that directory and give PHP-FPM ownership:

sudo mkdir -p /usr/share/phpmyadmin/tmp
sudo chown www-data:www-data /usr/share/phpmyadmin/tmp

Step 5: Raise PHP upload limits (optional but recommended)

PHP's default 2 MB upload limit blocks most real database imports. Raise it in the FPM configuration:

sudo nano /etc/php/8.3/fpm/php.ini

Find and update these two lines:

upload_max_filesize = 64M
post_max_size = 64M

Save, then restart PHP-FPM so the change takes effect:

sudo systemctl restart php8.3-fpm

Step 6: Verify it worked

Open http://your-server-ip/phpmyadmin in a browser. You should see the phpMyAdmin login screen. Log in with the pma_admin user you created. The dashboard should show your server, databases, and a green checkmark under "Database server" with no red warnings at the bottom.

Run a quick functional test: create a database called test_pma, create a table inside it, insert one row, then delete the database. If all of that works through the web UI, the install is fully functional. You can also confirm from the shell:

curl -s -o /dev/null -w "%{http_code}" http://localhost/phpmyadmin/

A 200 response means Nginx is serving phpMyAdmin correctly.

Common issues and fixes

404 Not Found on /phpmyadmin

The symlink is missing or Nginx serves a different document root. Recreate the symlink with sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin and check the root directive in your Nginx server block points to /var/www/html.

Blank white page or "The mbstring extension is missing"

You skipped the PHP extensions. Install them and restart PHP-FPM:

sudo apt install -y php-mbstring php-zip php-gd php-xml php-curl
sudo systemctl restart php8.3-fpm

"Access denied" when logging in as root

Expected behavior on Ubuntu 24.04: root uses auth_socket and cannot log in via the web form. Log in with the dedicated pma_admin user from Step 3 instead.

"The configuration file now needs a secret passphrase"

You skipped the blowfish secret. Add a 32-character $cfg['blowfish_secret'] in /etc/phpmyadmin/config.inc.php as shown in Step 4 and reload the page.

phpMyAdmin asks to log in again on every click

The temp directory is missing or not writable by PHP-FPM. Create /usr/share/phpmyadmin/tmp and set ownership to www-data as shown in Step 4.

Step 7: Add a password gate in front of phpMyAdmin (recommended)

phpMyAdmin login pages are scanned constantly by bots. A second HTTP basic-auth layer in Nginx stops automated attacks before they even reach the login form. Create a password file with the apache2-utils package (it provides the htpasswd tool):

sudo apt install -y apache2-utils
sudo htpasswd -c /etc/nginx/.pma_passwd pmauser

The -c flag creates the file; omit it when adding more users later. Then add a location block to your Nginx server config:

sudo nano /etc/nginx/sites-available/default
location /phpmyadmin {
    auth_basic "phpMyAdmin restricted";
    auth_basic_user_file /etc/nginx/.pma_passwd;
}

Test and reload:

sudo nginx -t
sudo systemctl reload nginx

Now visiting /phpmyadmin first asks for the pmauser password, and only then shows the phpMyAdmin login for your database user. Two independent credentials means a leaked database password alone is useless to an attacker who cannot pass the web gate.

Hardening tips before going to production

  • Use HTTPS: install a free certificate with sudo certbot --nginx so database credentials never travel in plain text.
  • Restrict access by IP: wrap the location in an allow/deny block so only your office IP can reach /phpmyadmin.
  • Rename the URL: move the symlink to something unpredictable like /var/www/html/db-panel-9x2 to dodge automated scanners.
  • Add HTTP basic auth: a second password prompt in front of the login page stops brute-force bots cold.

Keeping phpMyAdmin updated

Because phpMyAdmin is internet-facing and handles database credentials, patch it promptly. The Ubuntu repository version updates with normal system upgrades:

sudo apt update
sudo apt upgrade -y

Check your installed version from the phpMyAdmin home page (it shows in the footer) against phpmyadmin.net. If Ubuntu's package lags behind a security release, you can download the upstream release as a stopgap, but for most servers the repository version with unattended security upgrades is the right balance of safety and simplicity.


You now have phpMyAdmin 5.2 running on Ubuntu 24.04 behind Nginx with PHP-FPM, a dedicated admin user, correct upload limits, and a hardened configuration. If server setups like this eat into your development time, XpertBees handles server configuration, hardening, and managed hosting for teams that would rather ship product. Reach out through our contact page and we will take the ops work off your plate.