(Last Updated On: May 2, 2019)

In today’s guide, we will discuss how you can Install phpMyAdmin on Debian 10 (Buster). phpMyAdmin is a free and Open source Web application written in PHP for administering MySQL and MariaDB database servers. It is mostly used by Developers and DBAs to interact with a database server because of its ease of use.

phpMyAdmin provides an advanced SQL editor which makes it easy to build and test complex SQL queries. It also allows you to manage Databases, Users, Data import and export, stored procedures and triggers, execute and edit queries, search database globally and much more.

This tutorial explains the steps for installing phpMyAdmin with Apache on Debian 10 (Buster). Let’s get started.

Step 1: Install PHP

PHP is the main software requirement for running phpMyAdmin. Install it using our guide below.

Install PHP on Debian 10

For simplicity, the commands below can be executed to install PHP and extensions required.

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

Step 2: Install MariaDB Database Server

If you don’t have existing Database server to manage, you can use our guide to install MariaDB database server on Debian 10.

How to Install MariaDB on Debian 10 Buster

Step 3: Install Apache Web Server

For this installation setup, we chose Apache as a web server to use with phpMyAdmin. You are free to choose whichever web server you prefer though, e.g Nginx.

Install Apache Web Server on Debian 10 by running the following commands

sudo apt-get -y install apache2

Step 4: Install phpMyAdmin on Debian 10

Visit phpMyAdmin downloads page and check for the latest release. As of this writing, this is version 4.8.5.

Download it it with wget command.

sudo apt-get install -y wget
export VER="4.8.5"
cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/${VER}/phpMyAdmin-${VER}-all-languages.tar.gz

For English language only package, use:

cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/${VER}/phpMyAdmin-${VER}-english.tar.gz

Extract downloaded Archive

tar xvf phpMyAdmin-${VER}-english.tar.gz

OR
tar xvf phpMyAdmin-${VER}-all-languages.tar.gz

Move the resulting folder to /usr/share/phpmyadmin folder.

rm phpMyAdmin*.gz
sudo mv phpMyAdmin-* /usr/share/phpmyadmin

Create directory for phpMyAdmin temp files.

sudo mkdir -p /var/lib/phpmyadmin/tmp
sudo chown -R www-data:www-data /var/lib/phpmyadmin

Create directory for phpMyAdmin configuration files such as htpass file.

sudo mkdir /etc/phpmyadmin/

Create phpMyAdmin configuration file.

sudo cp /usr/share/phpmyadmin/config.sample.inc.php  /usr/share/phpmyadmin/config.inc.php

Edit the file /usr/share/phpmyadmin/config.inc.php and set secret passphrase:

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

Configure Temp directory

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

Step 5: Configure Apache web Server

Create phpMyAdmin Apache configuration file.

sudo vim /etc/apache2/conf-enabled/phpmyadmin.conf

And paste below contents to the file:

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>

        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>
    <IfModule mod_php.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>

        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authz_core.c>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "phpMyAdmin Setup"
            AuthUserFile /etc/phpmyadmin/htpasswd.setup
        </IfModule>
        Require valid-user
    </IfModule>
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/templates>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Require all denied
</Directory>

You can restrict access from specific IP by adding line like below

Require ip 127.0.0.1 192.168.18.0/24

Restart apache web server.

sudo systemctl restart apache2

Step 5: Visit phpMyAdmin Web interface

Access phpMyAdmin Web interface on http://[ServerIP|Hostname]/phpmyadmin. Use your database credentials – username & password to login.

phpMyAdmin dashboard is displayed upon a successful login. It looks something like this:

Conclusion

You now have a phpMyAdmin installed on Debian 10. You can start managing your database server from a Web dashboard and stress less on mastering MySQL command line.

For other systems, check:

Install and Configure phpMyAdmin on Fedora

Install and Configure phpMyAdmin on RHEL / CentOS 8