How To Install phpMyAdmin on Debian 11/Debian 10

ComputingPost
3 min readSep 24, 2022

--

In today’s guide, we will discuss how you can Install phpMyAdmin on Debian 10 / Debian 11 Linux. 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 11 / Debian 10 Linux system. Let’s get started.

Step 1: Install PHP on Debian 11 / Debian 10

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

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

sudo apt -y update

sudo apt -y install wget php php-cgi php-mysqli php-pear php-mbstring 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.

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 system by running the following commands

sudo apt-get -y install wget apache2

Step 4: Install phpMyAdmin on Debian 10 / Debian 11

You can check the released of phpMyAdmin from the downloads page. Thanks William Desportes for the hint on how to pull the latest release of phpMyAdmin.

Download latest version of phpMyAdmin with wget command.

DATA="$(wget https://www.phpmyadmin.net/home_page/version.txt -q -O-)"

URL="$(echo $DATA | cut -d ' ' -f 3)"

VERSION="$(echo $DATA | cut -d ' ' -f 1)"

wget https://files.phpmyadmin.net/phpMyAdmin/$VERSION/phpMyAdmin-$VERSION-all-languages.tar.gz

For English language only package, use:

wget https://files.phpmyadmin.net/phpMyAdmin/$VERSION/phpMyAdmin-$VERSION-english.tar.gz

Extract downloaded Archive:

tar xvf phpMyAdmin-$VERSION-all-languages.tar.gz

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

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:

$ sudo vim /usr/share/phpmyadmin/config.inc.php

$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





Options SymLinksIfOwnerMatch

DirectoryIndex index.php







AddType application/x-httpd-php .php





SetHandler application/x-httpd-php





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







AddType application/x-httpd-php .php





SetHandler application/x-httpd-php





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









# Authorize for setup







AuthType Basic

AuthName "phpMyAdmin Setup"

AuthUserFile /etc/phpmyadmin/htpasswd.setup



Require valid-user







# Disallow web access to directories that don't need it



Require all denied





Require all denied





Require all denied

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 6: Visit phpMyAdmin Web interface

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

phpmyadmin-debian-10-login

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

phpmyadmin-debian-10-dashboard-1024x546

--

--

ComputingPost

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.