Install phpMyAdmin and Configure with Nginx on Ubuntu 22.04

Jul 04, 2022 . Admin

Hi Guys,

Now, let's see example of How to Install phpMyAdmin with Nginx on Ubuntu 22.04?. Here you will learn Nginx and phpMyAdmin install. it's simple example of Install PHPMyAdmin in Few Simple Steps. if you have question about Secure phpmyadmin site with nginx then I will give simple example with solution.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Step 1: Update System Dependencies

The tutorial, it is good to ensure your system is up-to-date with all existing packages to avoid any conflicts during the installation.

$ sudo apt update
Step 2: Install phpMyAdmin

we install phpmyadmin with the following command:

$ sudo apt-get install phpmyadmin

Then, we hit Tab when the prompt asks about bypassing the webserver.

After that, the next prompt will ask whether we want to configure a database for PHPMyAdmin with dbconfig-common’s help.

Step 3: Configure phpMyAdmin with Nginx

Then, we create a symbolic link to the Nginx document root directory from the installation files with the following command:

$ sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html

After the above process, we have to set up phpMyAdmin as a virtual host as well as a subdomain:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}   

The new file inside the server block from where wish to access phpMyAdmin.

server {
    . . .

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    server_name db.epicmath.com;

    . . .
}

Step 4: Restart Web Server

Test the Installation of PHPMyAdmin

$ systemctl restart nginx
Step 5: Restart Web Server

You can now access the web interface by visiting your server’s domain name or public IP address followed by /phpmyadmin:

https://your_domain_or_IP/phpmyadmin
#Ubuntu