How to Install PHPMyAdmin with Nginx on Ubuntu 22.04

How to Install PHPMyAdmin with Nginx on Ubuntu 22.04

phpMyAdmin is a free software tool written in PHP that is intended to handle the administration of a MySQL or MariaDB database server. You can use phpMyAdmin to perform most administration tasks, including creating a database, running queries, and adding user accounts.

Install PHPMyAdmin with Nginx on ubuntu 22.04; Through this tutorial, we will learn how to install and use PHPMyAdmin with Nginx on linux ubuntu 22.04.

How to Install PHPMyAdmin Nginx in Ubuntu 22.04

Steps to install and use PHPMyAdmin with Nginx in linux ubuntu 22.04 using command line or terminal:

  • Step 1 – Update System Dependencies
  • Step 2 – Install PHPMyAdmin
  • Step 3 – Configure phpMyAdmin with Nginx
  • Step 4 – Restart Web Server
  • Step 5 – Test the Installation of PHPMyAdmin

Step 1 – Update System Dependencies

Open a terminal and execute the following command on the command line to update system dependencies:

sudo apt update

Step 2 – Install PHPMyAdmin

Then execute the following command on the command line to install phpMyAdmin with nginx on ubuntu 22.04:

sudo apt install phpmyadmin

Once the PHPMyAdmin installation has been done, then open a 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.

Step 3 – Configure phpMyAdmin with Nginx

Now, configure PHPMyAdmin with Nginx by creating a symbolic link.

Use the following command to create a new configuration for phpMyAdmin:

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

Add the following to the new file. Make sure, 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.0-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.

Then, add the new file inside the server block from where wish to access phpMyAdmin.

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

server {
    . . .

    include snippets/phpmyadmin.conf;

    . . .
}

Step 4 – Restart Web Server

Then execute the following command on command line to restart Nginx for the changes to take effect:

sudo service nginx restart

Step 5 – Test the Installation of PHPMyAdmin

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

https://domain.com/phpmyadmin

Conclusion

Through this tutorial, we have learned how to install phpMyAdmin on Ubuntu 20.04 with Nginx.

Recommended Linux Ubuntu Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *