phpMyAdmin is a free web-based interface for managing MySQL/MariaDB databases. This guide installs phpMyAdmin on Ubuntu 24.04 LTS with Nginx and PHP 8.3.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.04 LTS server
  • Nginx, MySQL, PHP 8.3-FPM installed
  • A user with sudo privileges

Step 1 – Install phpMyAdmin

Install from the Ubuntu repository:

sudo apt update
sudo apt install phpmyadmin -y

During installation: select apache2 if prompted (we’ll configure manually for Nginx), and set the application password when asked.

Step 2 – Create a Symlink for Nginx

Link phpMyAdmin to the web root:

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

Step 3 – Configure Nginx

Add a location block to your Nginx server block:

location /phpmyadmin {
    root /var/www/html;
    index index.php;
    location ~ ^/phpmyadmin/.+.php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Step 4 – Test and Reload Nginx

Validate configuration and reload:

sudo nginx -t
sudo systemctl reload nginx

Step 5 – Create a phpMyAdmin Admin User

Log into MySQL and create a dedicated phpMyAdmin user:

sudo mysql
CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'StrongPmaPass123!';
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Step 6 – Access phpMyAdmin

Open a browser and navigate to https://your_server_ip/phpmyadmin. Log in with your MySQL credentials.

Step 7 – Restrict Access by IP (recommended)

Inside the Nginx location block, add:

allow 203.0.113.0/24;   # your office IP range
deny all;

Conclusion

phpMyAdmin is now accessible on your Ubuntu 24.04 LTS server. Always restrict access to trusted IPs and use HTTPS to protect database credentials during transit.