YouTube Icon

Code Playground.

How to Install phpMyAdmin with Nginx on Ubuntu 18.04


How to Install phpMyAdmin with Nginx on Ubuntu 18.04

phpMyAdmin is an open-source PHP based instrument for overseeing MySQL and MariaDB workers over an online interface. 

phpMyAdmin permits you to cooperate with MySQL information bases, oversee client records and advantages, execute SQL-proclamations, import and fare information in an assortment of information configurations and significantly more. 

This instructional exercise depicts how to introduce phpMyAdmin with Nginx on Ubuntu 18.04. 


Guarantee that you have met the accompanying requirements prior to proceeding with this instructional exercise: 

LEMP (Linux, Nginx, MySQL, and PHP 7) introduced on your Ubuntu worker . 

Signed in as a client with sudo advantages . 

Albeit a bit much, it is strongly prescribed to get to your phpMyAdmin occurrence over HTTPS. On the off chance that you don't have SSL empowered on your destinations, check our article about how to make sure about your Nginx with Let's Encrypt on Ubuntu 18.04 . 

Installing phpMyAdmin on Ubuntu

Introducing phpMyAdmin is a genuinely straightforward errand. Start by refreshing the bundles list: 

sudo apt update

Next, run the accompanying order to introduce the phpMyAdmin bundle from the default Ubuntu archives: 

sudo apt install phpmyadmin

Ensure you have Nginx and PHP FPM introduced on your framework prior to introducing phpMyAdmin. 

The installer will ask you pick the web worker that should be naturally arranged to run phpMyAdmin. There is no choice to pick Nginx, press TAB to choose OK and afterward Enter. We'll design Nginx in the following area. 

Next, the installer will find out if you need to utilize dbconfig-regular device to set up the information base. Select Yes and hit Enter. 

Enter a secret phrase for phpMyAdmin to enroll with the information base, select OK and press Enter. 

You will be incited to affirm the secret phrase, enter a similar secret key, select OK and press Enter. 

Now phpMyAdmin has been introduced on your Ubuntu worker. 

Create an Administrative MySQL User

In Ubuntu frameworks running MySQL 5.7 (and later), the root client is set to utilize the auth_socket validation strategy naturally. 

The auth_socket module confirms clients that interface from the localhost through the Unix attachment document. This implies that you can't validate as a root by giving a secret word. 

Rather than changing the verification strategy for the MySQL client root, we will make another authoritative MySQL client. This client will have similar advantages as the root client and will be set to utilize the mysql_native_password verification strategy. 

We will utilize this client to login to the phpMyAdmin dashboard and preform authoritative assignments on our MySQL worker. 

Start by sign in to the MySQL worker as the root client: 

sudo mysql

From inside the MySQL shell execute the accompanying orders which will make another authoritative client and award proper consents: 

CREATE USER 'padmin'@'localhost' IDENTIFIED BY 'change-with-your-secure-password';

In this model we named the authoritative client padmin. You can utilize any name you like, simply make certain to set a solid secret phrase. 

Configuring Nginx and phpMyAdmin 

There are a few different ways how to design the Nginx to serve phpMyAdmin records. In the event that your area's worker block is as of now set up to serve the PHP demands then you can just make an emblematic connection from the phpMyAdmin establishment records to your space report root catalog. 

In this guide we will make a piece which we can remember for any of our Nginx worker block records. 

Open your word processor and make the accompanying record: 

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

Glue the accompanying substance: 


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/php7.2-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/;

Ensure you are utilizing the right attachment way or address/port for the fastcgi_pass mandate. 

Spare the record and close your supervisor. 

You would now be able to add the accompanying line to every area's worker block where you need to get to phpMyAdmin utilizing: 

include snippets/phpmyadmin.conf;


Here is a model: 


server {

    # . . . other code

    include snippets/phpmyadmin.conf;

    # . . . other code 


Accessing phpMyAdmin

To get to the phpMyAdmin interface open your #1 program and type your worker's area name or public IP address followed by/phpmyadmin: 


Enter the managerial client login qualifications and snap Go. 

When you sign in, you'll see the phpMyAdmin dashboard, which will look something like this: 


Congrats, you have effectively introduced phpMyAdmin on your Ubuntu 18.04 worker. You would now be able to begin making MySQL information bases, clients and tables and perform different MySQL inquiries and activities. 

In the event that you have questions, don't hesitate to leave a remark underneath.