In today’s guide, we will discuss how you can Install phpMyAdmin on Debian 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 Linux system. Let’s get started.
1 – Install PHP
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
2 – Install MariaDB Database Server
If you don’t have
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
4 – Install and Configure phpMyAdmin
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 /usr/share/phpmyadmin
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';
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
6 – Visit phpMyAdmin Web interface
Access phpMyAdmin Web interface on http://[ServerIP|Hostname]/phpmyadmin. Use your database credentials – username & password to

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

Recommended books to read:
- Best Books to learn Web Development – PHP, HTML, CSS, JavaScript and jQuery
- Best Books To Master Web Design
- Best Books To Learn CSS & CSS3
- Best Books To Learn HTML & HTML5
- Best Apache and Nginx reference Books
Conclusion
You now have a phpMyAdmin installed on Debian Linux system. You can start managing your database server from a Web dashboard and stress less on mastering MySQL command line.
For other systems, check:
This was a huge help for getting phpmyadmin 5.1.1 up on my Debian Sid machine. There are obviously a few gotchas still around though.
php-mysqli is now part of php-mysql
phpmyadmin first crashed with a pcre-related error, updating to the latest libpcre2-8-0 fixed it.
This was a good article on LAMP installation. Only one required was adding mysql extension, I had to uncomment the existing line extension in php.ini to remove mysqli extension missing error. When I rebooted apache2 server and accessed phpMyadmin webpage. Once I added the mysqli extension in the php.ini under Dynamic Extensions usng the below line.
extension=mysqli
everything started working fine. I could login into DB with root user.
Thanks
Thank you so much Josphat Mutai. I setup phpmyadmin on my debian server within 5 minutes with the help of this artcile.
Happy to hear this positive news Musab. Most welcome!
Thank you very much for this , u saved my soul
This has really done the job. Thank you so much!
I’m sorry, whent I try to restart apache2 I get:
“apache2: Syntax error on line 229 of /etc/apache2/apache2.conf: Could not open configuration file /etc/phpmyadmin/apache.conf: No such file or directory”