Categories
Tutorials

How to Install phpMyAdmin on Debian 10?

After a long-time Debian upgraded their overall OS and for some reason phpMyAdmin is not there in Debian 10 (Buster) release. Maybe they have removed it this time from apt list to keep everything as clean as possible. However, we can install phpMyAdmin on Debian 10 from the source and it is kinda easy too. In this article, we will see how we can install and configure phpMyAdmin on Debian 10 Buster step by step.

If you don’t know what is phpMyAdmin, it is a free (open source) web software built on PHP for managing MySQL and MariaDB database servers. It is used by developers and database administrators to interact with the database server. The phpMyAdmin app offers a user interface on which anyone can manage databases.

phpMyAdmin on Debian 10

Let’s get started and follow the steps to install phpMyAdmin on Debian 10…

Just make sure you are logged in as a root user or a root privileged user. Otherwise, you’ll need to add sudo directive every time before using any command.

Step #1. Basic Web Server Installation

Update the Debian 10 with latest updates.

apt update

Now install NGINX as a web server software.

apt install nginx

Now install PHP7.3 and related packages.

Here I have added some extra packages too in order to make everything ready for any CMS software too like WordPress.

apt install php7.3-fpm php7.3-cli php7.3-common php7.3-curl php7.3-gd php7.3-mbstring php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-zip

Now install MariaDB software.

apt install mariadb-client mariadb-server

Run mysql_secure_installation to secure the MySQL server. You’ll be asked some questions like below just follow that. Make sure you set a strong password for root.

Enter current password for root (enter for none): ⏎ - Hit Enter
Set root password? [Y/n] ------------------------ Y
Remove anonymous users? [Y/n] ------------------- Y
Disallow root login remotely? [Y/n] ------------- Y
Remove test database and access to it? [Y/n] ---- Y
Reload privilege tables now? [Y/n] -------------- Y

Now our basic web server installation is just completed. We have NGINX as a web server, PHP as a dynamic content handler, and MariaDB as in MySQL database.

Step #2. Install and Configure phpMyAdmin

Here all we need to do is grab an installation file from the source and set it up.

You can go to phpMyAdmin’s download section to fetch the latest software link. In my case, it is phpMyAdmin 4.9.0.1 so I am going to use English only version of it.

I’m going to set it up on /var/www/html location. You can use any location; there is no restriction, just use the same path everywhere ahead including Nginx’s config file.

Use one line of command at a time. It is good to see what is happening actually.

cd /var/www/html/
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-english.zip
apt install zip unzip -y
unzip phpMyAdmin-4.9.0.1-english.zip
cd phpMyAdmin-4.9.0.1-english/
mv * /var/www/html/
cd ..
rm phpMyAdmin-4.9.0.1-english.zip
rm -rf phpMyAdmin-4.9.0.1-english/

The phpMyAdmin uses a temporary folder to cache a few things. So we need to create a tmp folder and allow it all the permissions. Just run below commands.

mkdir tmp
chmod 777 tmp/

Now we have phpMyAdmin files at the place. All we need to do is configure it to work.

mv config.sample.inc.php config.inc.php

Now we need to edit some of the lines in the config file.

nano config.inc.php

Be careful here, and read twice while doing anything.

Add blowfish secret key to secure the sessions.

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

To generate your one click here and copy the auto-generated blowfish_secret.

Now add that key to the config file like mentioned below.

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

Note: Do not copy our secret key, it is just for demonstration and weak.

Now scroll down to the phpMyAdmin configuration storage settings below that under User used to manipulate with storage just uncomment control user and pass.

/* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapass';

Let the user as it is but change the pmapass to a strong password. This password will be used ahead while creating pma user for phpmyadmin database.

Now scroll below to Storage database and tables and uncomment full storage database and tables section.

/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

These tables don’t yet exist in the database, but we will create them shortly.

Now all the configurations are made. Save it by Ctrl+O and exit nano editor by Ctrl+X.

Next, we’ll need to create the phpMyAdmin storage database and tables. By the following command we can use the create_tables.sql file located under the sql folder to create the configuration storage database and tables:

mariadb < sql/create_tables.sql

This will create a phpmyadmin database and create the required tables for storage uses.

Next, we need to create a pma user and grand it the necessary permissions.

mariadb
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';

Here we’ll need a root user alternative as we have disabled its remote access; this will be the login ID and Password for phpMyAdmin web access.

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'usersecret' WITH GRANT OPTION;
exit

Change the username with the desired password and remember it. You’ll need this every time while login to the phpMyAdmin dashboard.

Step #3: Configure NGINX for phpMyAdmin

Now let’s configure Nginx to enable phpMyAdmin on Port 80, which will be the frontend.

nano /etc/nginx/sites-available/default

You can configure settings here as you want to. Just for this tutorial, I am going to configure it to access it on a direct IP address of the server.

server {
        listen 80;
        listen [::]:80;
        root /var/www/html;
        index index.php;
        server_name _;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ .php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        }
}

Just copy the above-mentioned configs to default file and save it. Save it by Ctrl+O and exit nano editor by Ctrl+X. You can play with the configs as you want like change the port 80 to something else for security reasons or HTTP authenticate the access and more.

Now restart the Nginx services once in order to fetch new commands in action.

service nginx restart

Everything is done now. You have a full-fledge working phpMyAdmin on Debian 10.

To access it, based on our setup, open browser and enter the IP address of the server.

Like: http://server-IP-address

PHPMyAdmin Login

Boom we will see phpMyAdmin login page. Just login with the newly created username and usersecret which we have created above.

Related Tutorials:

By AtulHost

Hi, I'm Atul Kumar Pandey; also known as AtulHost on the web, a full-time blogger by profession with an objective of sharing fresh and honest contents in business and technology niche.

4 replies on “How to Install phpMyAdmin on Debian 10?”

Glad to know that everything worked for you. Just secure the public access of the phpMyAdmin either via a unique port or HTTP authentication. Good Luck!

Comments are closed.