Linux MySQL

Install phpMyAdmin on Debian 11 with Nginx

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

PhpMyAdmin is a web-based application for interacting with MySQL database server. This tool provides you with a user interface to make MySQL operations so you don’t have to use the command line interface.

In this guide you are going to learn how to install PhpMyAdmin with Nginx on Debian 11 and secure it.


Make sure you have LEMP setup in your server with Nginx, PHP and MySQL/MariaDB. If you don’t have the server setup you can follow the below guide to setup.
How to Install LEMP Nginx, MySQL, PHP in Debian 11

Also setup server blocks to server PHP application.

Install phpMyAdmin

Once you have Nginx, PHP, MySQL installed you can start installing phpMyAdmin.

There are different ways to install phpMyAdmin, here we will follow the easiest way to install it.

Execute the below command to install phpMyAdmin.

sudo apt install phpmyadmin

In the prompt to choose web server, press TAB to skip this.

When prompted again to allow dbconfig-common to install a database and configure select Yes and press ENTER.

Then type and confirm a password or allow to use any random password.

Configure phpMyAdmin with Nginx

Once phpMyAdmin is installed you can configure it with Nginx so you can access the web interface.

There are several ways to accomplish this, you can just create a symbolic link of /usr/share/phpmyadmin directory to your web root.

Here we will learn now to create a new configuration for phpMyAdmin.

sudo nano /etc/nginx/snippets/phpmyadmin.conf

Add the following to the new file. Make sure you use the correct PHP version.

location /phpmyadmin {
    root /usr/share/;
    index index.php index.html index.htm;
    location ~ ^/phpmyadmin/(.+.php)$ {
        try_files $uri =404;
        root /usr/share/;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;

    location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
        root /usr/share/;

Save the file and exit.

Include the new file inside your server block from where you wish to access phpMyAdmin.

Edit your server block configuration which will be located inside /etc/nginx/sites-available and include the snippet so your configuration looks something similar to the one below.

server {
    . . .

    include snippets/phpmyadmin.conf;

    . . .

Restart Nginx for the changes to take effect.

sudo service nginx restart

Now you can access phpMyAdmin using your domain followed by /phpmyadmin.


Now you have learned how to install phpMyAdmin on Debian 11 with Nginx.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.