Rate this post

Last Updated on September 18, 2022 by Vikash Ekka

How To Install phpMyAdmin on Ubuntu 22.04 with Nginx | vetechno
How To Install phpMyAdmin on Ubuntu 22.04 with Nginx | vetechno


In this tutorial guide, you are going to learn how to install phpMyAdmin with Nginx on Ubuntu 22.04 LTS Jammy Jellyfish. The phpMyAdmin package is available for Ubuntu 22.04, 20.04 and 18.04. on the official page . If you need to install the latest phpMyAdmin on Ubuntu, you wiil have to download the .zip package from the official 
phpMyAdmin releases page.

What is PhpMyadmin ?

 

PhpMyAdmin is a web-based application where users can interact with MySQL / MariaDB 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.

 

I will show you the step-by-step installation of the phpMyAdmin on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 20.04, 18.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

 

How to Install LAMP Apache, MySQL, PHP in Ubuntu 22.04

 

Step 1. Install PHP on Ubuntu 22.04 LTS Jammy Jellyfish.

 

Before moving forward we need to first install PHP and its module on our Ubuntu system, because PhpMyAdmin is written in PHP.

Click here to get all PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 & 8.1 commands with all module or extensions.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl php7.4-json php7.4-fpm 

Step 2.  Install MySql/MariaDB Database Server (Optional)

sudo apt install mysql-server                  ## MySql Server               
sudo apt install mariadb-server              ## MariaDB Server

 Step 3. Install Nginx Web Server

sudo apt install nginx

Step 4. Download phpMyAdmin on Ubuntu 22.04 LTS .

 

Download latest version of phpMyAdmin with wget command. You can check the release of phpMyAdmin from the downloads page.

wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip

 Now extract downloaded Archive with unzip command below

sudo apt install unzip
unzip phpMyAdmin-5.2.0-all-languages.zip

Rename the directory to phpmyadmin

mv phpMyAdmin-5.2.0-all-languages phpmyadmin

 Now move phpmyadmin folder under the /var/www/html/.

mv phpmyadmin /var/www/html/

Create phpMyAdmin config.inc.php file.

sudo cp /var/www/html/phpmyadmin/config.sample.inc.php  /var/www/html/phpmyadmin/config.inc.php

Create tmp directory in phpmyadmin folder

sudo mkdir -p /var/www/html/phpmyadmin/tmp

Now, generate a 32-bit random string:

openssl rand -base64 32

OUTPUT:-

VqNjq4CPFh4rJUctDwwc80zqY01IpMv8c+yDLc/P8aw=

Above key is secret Passphrase key. (Note:- If not work then apply below key)

P5DS+radU0TOqI7HX$cH!eb3zwnDDoDr

Edit the file /var/www/html/phpmyadmin/config.inc.php.

sudo vim /var/www/html/phpmyadmin/config.inc.php

find the line and Enter the secret passphrase:

$cfg[‘blowfish_secret’] = ‘your-key‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Also, scroll down to the same file end and add below line.

$cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';

Step 5. Enable PHP-FPM service on Port 9000

Add Listen =127.0.0.1:9000 to make PHP-FPM listen on the localhost network.

sudo vim /etc/php/7.4/fpm/pool.d/www.conf

OUTPUT:-

How To Install phpMyAdmin on Ubuntu 22.04 with Nginx | vetechno
Enable PHP-FPM service

Restart PHP-FPM service.

sudo service php7.4-fpm restart
Check Running Port 
sudo apt install net-tools
sudo netstat -tupln
OUTPUT:

root@vetechno:/home/user# netstat -tupln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      17846/php-fpm: mast 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      17872/nginx: master  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      16622/sshd: /usr/sb 
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      17425/mysqld        
tcp6       0      0 :::80 

Step 6. Configure Nginx Conf file.

Create phpMyAdmin Nginx configuration file and And paste below contents to the phpmyadmin.conf file:

sudo vim /etc/nginx/sites-available/phpmyadmin.conf

Here I am running phpMyAdmin on port number 81.

server {
        listen   81;
        server_name localhost;
        root /var/www/html/phpmyadmin;

    access_log  /var/log/nginx/phpmyadmin_access.log;
    error_log   /var/log/nginx/phpmyadmin_error.log;

location / {
        index  index.php;
        }

## Images and static content is treated differently
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
        access_log        off;
        expires           30d;
    }

location ~ /.ht {
        deny  all;
        }

location ~ /(libraries|setup/frames|setup/libs) {
        deny all;
        return 404;
    }

location ~ .php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/html/phpmyadmin$fastcgi_script_name;
                    }
    }

 Create symbolic link

ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/

 Test Nginx configuration and Restart Nginx Service

nginx -t
sudo service nginx restart
Check Port 81 is running or not.
sudo netstat -tupln
OUTPUT:

root@vetechno:/home/user# netstat -tupln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      17846/php-fpm: mast 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      17872/nginx: master 
tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN      17872/nginx: master 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      16622/sshd: /usr/sb 
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      17425/mysqld        
tcp6       0      0 :::80                   :::*                    LISTEN      17872/nginx: master 
tcp6       0      0 :::22                   :::*                    LISTEN      16622/sshd: /usr/sb 
udp        0      0 127.0.0.53:53           0.0.0.0:*                           16646/systemd-resol 

Step 7. Access phpMyAdmin web interface.

Enter the server IP address or domain name along with port 81 in the browser URL address to access phpMyAdmin web interface.

 

For Example:-

http://localhost:81
OR
https://server-ip-address:81
OR
http://your-domain.com:81

Enter the MySQL database root user and password to login phpMyAdmin web interface.

 

How To Install phpMyAdmin on Ubuntu 22.04 with Nginx | vetechno
Access phpMyadmin web interface

 

Conclusion

 

Congratulation you have successfully installed the phpMyAdmin on Ubuntu 22.04 LTS Jammy Jellyfish.  This method will also work on Ubuntu 18.04 LTS and Ubuntu 20.04 LTS. If you have any doubt let me know in this comment box.

 

You May Also Link


By Vikash Ekka

Hi All, My name is Vikash Ekka from India. I’m the founder and tech editor of https://www.vetechno.in. I have completed my Graduation in BCA. I love to write technical articles like Windows, Linux & MAC Tutorials, Tips, Tricks, How To fix, Tutorials About Ethical Hacking & Cyber Security Guide, and Software Review. Currently, I have been working as an IT professional since 2018.

3 thoughts on “How To Install phpMyAdmin on Ubuntu 22.04 with Nginx | vetechno”

Leave a Reply

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