Log In

How to Install and Configure phpMyAdmin on Ubuntu 22.04

How to Install and Configure phpMyAdmin on Ubuntu 22.04
Reading time: 9 min
Hostman Team
Technical writer

phpMyAdmin is a specialized utility written in PHP that provides a graphical interface for managing MySQL databases via a browser. In addition to displaying tables visually, phpMyAdmin simplifies database management, allowing the creation of SQL queries through a control panel without directly writing commands or code. It implements the full functionality of SQL queries: viewing, adding, deleting, and modifying databases, as well as their tables, fields, and indexes.

In this guide, we will install phpMyAdmin and all its dependencies on a remote host. The technological stack within which phpMyAdmin will work is as follows:

  • MySQL database

  • Nginx web server

  • PHP interpreter

Note that this guide uses the Nginx web server instead of the more common Apache for PHP. Therefore, the overall toolset demonstrated in this instruction looks like this: PHP + phpMyAdmin + Nginx + MySQL. Thus, Nginx handles user requests and redirects them to PHP via the FastCGI protocol. The PHP interpreter processes phpMyAdmin scripts, which "communicate" with and manage the MySQL database.


To install and configure phpMyAdmin, you will need:

Below we will describe how to deploy an Ubuntu server on Hostman.

Step 1: Preparing the System

Configuring the Cloud Server

To create a cloud server on Hostman, log into the control panel and go to Cloud Servers in the left menu. Next, click Create server.

The most important thing is to choose Ubuntu 22.04. You can customize the rest of the parameters as you wish. After completing the configuration, click Order.

In a couple of minutes the server will be online and you'll be able to connect to it remotely via SSH, using the command:

ssh root@IP

For example:

ssh root@

You can copy the command from your server's Dashboard.

In our case, root is the default username for the Hostman cloud server. After entering the command, the terminal will prompt for the root password, which you also find on the Dashboard

B7da432f De03 4a5d A19a 7ae52cae30a9

Updating the System

Before installing the necessary components, update the list of available repositories:

sudo apt update

And update the packages already installed on the system:

sudo apt upgrade

Step 2: Installing MySQL

First, install MySQL on your Ubuntu server:

sudo apt install mysql-server -y

Ensure the MySQL service is running:

systemctl status mysql

If it is, the console output will include the following status:

Active: active (running)

You can also check the MySQL version:

mysql --version

The console will display something like this:

mysql  Ver 8.0.36-0 ubuntu for Linux on x86_64 ((Ubuntu))

Note that this guide uses MySQL version 8.0.36.

Next, run a special security script to configure MySQL:

sudo mysql_secure_installation

Log into MySQL to set a password for the root user:


Check the list of existing users:

SELECT User, Host FROM mysql.user;

The console will display a list of usernames and hosts:

| User             | Host      |
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
5 rows in set (0.00 sec)

We are interested in the root user, so execute the following command for it:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'my_pass_123';

Replace my_pass_123 with a strong password.

Exit MySQL:


In the future, to log into MySQL, use the following command:

mysql -u root -p

The console will always prompt for the password that you just set.

Step 3: Installing Nginx

In this example, we will use the Nginx web server as an alternative to Apache. Install it via the APT package manager:

sudo apt install nginx -y

After installation, check the status of the Nginx service:

systemctl status nginx

After installing, Nginx starts automatically, so the console output should show the status:

Active: active (running)

Check the Nginx version:

nginx -v

The console will display:

nginx version: nginx/1.18.0 (Ubuntu)

So, in this tutorial, phpMyAdmin will run on Nginx version 1.18.0.

Now you can enter your server's address in the browser to ensure that Nginx responds to user HTTP requests.

In our case:

The browser should open the standard Nginx welcome page.

After we install phpMyAdmin, it will be available at http://server-ip/phpmyadmin.

Step 4: Installing PHP

For phpMyAdmin to work, you need to install PHP on your Ubuntu server.

We will download it from an independent software provider's repository, so first add a new remote repository to the APT package manager:

sudo add-apt-repository ppa:ondrej/php

Then install the FastCGI Process Manager (FPM) and an additional module for working with MySQL:

sudo apt install php8.3-fpm php8.3-mysql -y

To check that the installation was successful, query the PHP version:

php -v

The console will display an output similar to this:

PHP 8.3.4 (cli) (built: Mar 16 2024 08:40:08) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.4, Copyright (c), by Zend Technologies

As you can see, this guide uses PHP version 8.3.4.

Step 5: Installing phpMyAdmin

To install phpMyAdmin on Ubuntu, download it from the official website. Select the latest version of the program in a .tar.gz archive, then copy the download link and use it in the wget command:

wget -c https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-english.tar.gz

Next, unpack the downloaded archive:

tar -xzvf phpMyAdmin-5.2.1-english.tar.gz

In our case, we are using phpMyAdmin version 5.2.1.

You can delete the archive itself:

rm phpMyAdmin-5.2.1-english.tar.gz

Move the unpacked directory to a separate directory specifically for phpMyAdmin:

sudo mv phpMyAdmin-5.2.1-english /usr/share/phpmyadmin

Create a symbolic link associated with the local host's web directory:

ln -s /usr/share/phpmyadmin /var/www/html

Now proceed to configure the Nginx web server.

Step 6: Configuring Nginx

Make changes to the web server's main configuration file to allow Nginx to open phpMyAdmin's root web page.

sudo nano /etc/nginx/sites-available/default

First, find the line defining the root page index parameter. By default, it looks like this:

index index.html index.htm index.nginx-debian.html;

To allow Nginx to process PHP files, add index.php so that the final line looks like this:

index index.php index.html index.htm index.nginx-debian.html;

Next, make changes to the FastCGI protocol handler so that Nginx can forward all requests to PHP files directly to the PHP interpreter. Find the root request handler code, which by default looks like this:

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;

Add the PHP file request handler code right after it:

location ~ \.php$ {
    try_files $fastcgi_script_name =404;
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

Overall, the file content should look like this:

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	root /var/www/html;

	index index.php index.html index.htm index.nginx-debian.html;

	server_name _;

	location / {
		try_files $uri $uri/ =404;

	location ~ \.php$ {
		try_files $fastcgi_script_name =404;
		include fastcgi_params;
		fastcgi_pass unix:/run/php/php8.3-fpm.sock;
		fastcgi_index index.php;
		fastcgi_param DOCUMENT_ROOT $realpath_root;
		fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

Check the Nginx configuration:

nginx -t

If the syntax is correct, the console will display:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart the Nginx web server to apply all changes:

sudo systemctl restart nginx

At this point, all the necessary dependencies are installed, and you can access phpMyAdmin by going to:


For example:

The main phpMyAdmin page should open in the browser.

3922b108 B5e3 44d1 8002 59483bbb042d

You can login to phpMyAdmin using the username and password of the MySQL user created to access the control panel and start managing databases.

D7570f05 1ae5 4fab B341 847cda00271a

Hostman Cloud Databases

As an alternative to deploying databases and management tools, Hostman provides pre-configured and ready-to-use cloud databases, including MySQL, PostgreSQL, Redis, MongoDB, and others.

MySQL and PostgreSQL databases have pre-installed web-interfaces for database management: phpMyAdmin and Adminer.

To create a cloud database, log in to the Hostman control panel and select Databases in the left sidebar menu. Click Create database. This will open the cloud database configuration page, which is similar to the cloud server configuration pages.

In our case, we choose MySQL as the database type. However, in your projects, you can use any other databases.

To apply the selected settings, you need to click the Order button. After this, you will be redirected to the main cloud database management page.

Cb85a25d 1405 4893 A3d2 B3cc82f5ac70

The database will be configured and started in a few minutes, after which it will be available for work through the web interface or remote connection.

To work with the database through the console terminal, you need to go to the Connection tab and copy the command to connect to the remote database via the MySQL client.

For example, the connection command might look like this:

mysql -u gen_user -p')<07dCV46*GdPE' -h -P 3306 -D default_db
  • After the -u flag, specify the username.

  • After the -p flag, specify the root password in single quotes.

  • After the -h flag, specify the IP address of the remote host.

  • After the -P flag, specify the host port (for example, the standard port for MySQL is 3306, and for MongoDB, it is 27017).

  • After the -D flag, specify the database name.

Alternatively, in the upper left corner, you can click on the Web Interface button and choose one of the two available database management utilities.

B1661df5 91c3 42d6 Bafd 5948ca5d1e60

After this, a familiar login page will open in a new tab, where you will need to enter the login credentials for the database.


This tutorial demonstrated the installation and configuration of phpMyAdmin with the preliminary manual installation of all necessary dependencies:

  • MySQL database

  • Nginx web server

  • PHP interpreter in FPM format

In your own projects, you can expand the technological stack shown in this guide to a more familiar and common combination of Nginx + Apache + PHP.

Additionally, as an alternative to manually deploying MySQL and phpMyAdmin, the creation of a pre-configured and ready-to-use cloud database on Hostman servers with pre-installed web-based database management interfaces, one of which is phpMyAdmin, was demonstrated.