Introduction

The phpMyAdmin utility is a graphical database management tool. By installing phpMyAdmin, you no longer need to use a default command-line interface to manage your databases.

PhpMyAdmin is a web-based application and requires the LAMP stack to work properly. This guide shows you how to lay the groundwork and install phpMyAdmin on Debian 10.

tutorial on how to Install and Secure phpMyAdmin on Debian 10

Prerequisites

Step 1: Install LAMP Stack on Debian 10

You need a functioning web server for phpMyAdmin to work properly. This section shows you how to install the supporting software to turn your Debian 10 system into a web server.

If you already have a LAMP stack installed, you can skip directly to the Download phpMyAdmin section.

Step 1.1: Update Software Packages and Install wget

Access your terminal window, and update your software package lists using the following command:

sudo apt update

Installing outdated software packages is a severe security liability. Do not skip this step.

The wget utility allows you to download files directly from the terminal window. Enter the following command to install the wget tool:

sudo apt install wget -y

You now have the tools you need to install a LAMP stack and phpMyAdmin.

Step 1.2: Install Apache

Apache is the webserver software that processes requests and transmits data over an HTTP network. Open a terminal window, and install Apache by entering the following command:

sudo apt install apache2 -y

The process can take a few moments to complete. Enter the following command to make sure the Apache service is running:

systemctl status apache2

In the report that follows, you should see a green status that says active (running).

Status of Apache web-server on Debian 10.

Press Ctrl+z to return to the command prompt.

Step 1.3: Install PHP on Debian 10

The PHP programming language and coding environment is essential for running a web application like phpMyAdmin. Install core PHP packages and Apache and MySQL plugins with the following command:

sudo apt install php php-cgi php-mysqli php-pear php-mbstring php-gettext libapache2-mod-php php-common php-phpseclib php-mysql -y

Once the installation process is complete, verify that PHP has been installed:

php --version

The system displays the current version of PHP, along with the date of the release.

The version of PHP currently intalled on Debian 10 system.

Step 1.4: Install and Set Up MariaDB on Debian 10

This guide uses the MariaDB open-source relational database management system instead of MySQL. MariaDB and MySQL are compatible, and many of the commands and features are identical.

To install MariaDB, enter the following command into your terminal:

sudo apt install mariadb-server mariadb-client -y

Once the process is complete, verify the MariaDB installation with the following command:

systemctl status mariadb

Like with Apache, you see an active (running) status.

System confirms that the MariaDB service is active and running on Debian 10.

Before installing phpMyAdmin, you need to configure the MariaDB database.

Secure MariaDB

Configure basic MariaDB security features by launching a built-in script:

sudo mysql_secure_installation

As you have not yet set a root password for your database, hit Enter to skip the initial query. You are now presented with the following options:

      • Set root password? [Y/n] – Type y and press Enter to create a strong root password for your database.
      • Remove anonymous users? [Y/n] – Type y and press Enter.
      • Disallow root login remotely? [Y/n] – Type y and press Enter.
      • Remove test database and access to it? [Y/n] – Type y and confirm with Enter.
      • Reload privilege tables now? [Y/n] – Type y and confirm with Enter.

The output confirms that your MariaDB installation is now secure.

screenshot showing you have successfully secured the MariaDB installation on Debian 10

Create a New MariaDB User

The phpMyAdmin utility needs a designated user to be able to connect to your database. Creating a new MariaDB user improves security and allows you to control the level of permissions granted to this user.

Use our detailed guide to create a new MariaDB user and grant privileges. Once you have set up a MariaDB user, you are ready to start the phpMyAdmin installation process.

Step 2: Download phpMyAdmin

Use the wget command to retrieve the latest stable version of phpMyAdmin:

wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

The -P option instructs wget to save the files directly in the Downloads directory. Feel free to specify any directory you see fit.

phpMyAdmin downloading in Debian 10


Note: At the time of writing this article, the latest version is phpMyAdmin 5.0.2. For a specific version, or to check the latest version, please see the developer’s download page.


Step 3: Check phpMyAdmin GPG Key

Each downloaded archive has a corresponding .asc file that contains its unique key signature. Once both files are in the same folder, the signature can be verified.

  1. To verify the GPG key for phpMyAdmin, download the phpMyAdmin keyring to the Downloads directory:
wget -P Downloads https://files.phpmyadmin.net/phpmyadmin.keyring
  1. Access the Downloads directory and import the keyring:
cd Downloads
gpg --import phpmyadmin.keyring

System imports gpg keyring to verigy phpmyadmin download files

  1. Download the corresponding GPG .asc file for your version of phpMyAdmin:
wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz.asc
  1. Access the Downloads directory and verify the .asc file against the keyring you downloaded:
cd Downloads
gpg --verify phpMyAdmin-latest-all-languages.tar.gz.asc

The system responds by displaying GPG key information.

output provides the GPG key to verify the downloaded files

You can now compare the GPG key to the developer credentials on the documentation page.

Step 4: Unpack and Configure phpMyAdmin

  1. Create a phpMyAdmin directory in the Apache web root directory:
sudo mkdir /var/www/html/phpMyAdmin
  1. Access the Downloads directory and unpack the phpMyAdmin tar.gz files to the newly created directory:
cd Downloads
sudo tar xvf phpMyAdmin-latest-all-languages.tar.gz --strip-components=1 -C /var/www/html/phpmyadmin
  1. Create a default configuration file:
sudo cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php
  1. Use the nano text editor (or your preferred text editor), to add a secret passphrase to the config.inc.php file:
sudo nano /var/www/html/phpmyadmin/config.inc.php

Locate the following line:

$cfg['blowfish_secret'] = '';

Add passphrase to the phpmyadmin config file.

Add a secret passphrase as follows:

$cfg['blowfish_secret'] = 'my_secret_passphrase';

Use a complex passphrase of your choice and then exit and save the file (Ctrl+x).

  1. Change the permissions for the config.inc.phpfile:
sudo chmod 660 /var/www/html/phpmyadmin/config.inc.php
  1. Change ownership of the phpmyadmindirectory:
sudo chown –R www-data:www-data /var/www/html/phpmyadmin
  1. Restart Apache:
sudo systemctl restart apache2

Step 5: Access phpMyAdmin from Browser

Use your preferred web browser and navigate to the following web address:

localhost/phpmyadmin

The system prompts the phpMyAdmin login screen and establishes a connection to the local Apache, MariaDB, and PHP files that you have created.

The phpMyAdmin logon page.

Log in to phpMyAdmin with the username and password for the MariaDB user you had created and granted privileges to.

The phpMyAdmin grahical user-interface.

Take your time and explore the many options and settings phpMyAdmin has to offer.

Conclusion

You have now installed phpMyAdmin on your Debian 10 system. Access the graphical user interface from your browser and start administering your databases more efficiently.


Next you should also read