Installing phpMyAdmin on Debian 10
In Debian 10 repositories, phpMyAdmin may not always be up to date. Therefore, installation from source code can be done to install the latest version.
In this guide:
-Apache -MariaDB
- PHP configuration
- blowfish_secret security
- phpMyAdmin meta tables
- open_basedir security
- .htaccess protection
Steps such as these are discussed in detail.
Prerequisites
- Debian 10 server
- User with authority
sudo - SSH or terminal access
Update Server
Update system packages before starting the installation.
sudo apt update && sudo apt upgrade -y
Installing Required Packages
Install Apache, MariaDB and necessary PHP modules for phpMyAdmin to work.
sudo apt install apache2 mariadb-server php php-cli php-mbstring php-zip php-gd php-json php-curl php-xml php-common unzip wget -y
Starting MariaDB Service
sudo systemctl start mariadb
sudo systemctl enable mariadb
MariaDB service will now start automatically at system startup.
Download phpMyAdmin Source Code
cd /usr/share
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip
sudo unzip phpMyAdmin-latest-all-languages.zip
sudo mv phpMyAdmin-*-all-languages phpmyadmin
sudo rm phpMyAdmin-latest-all-languages.zip
This will download the latest version of phpMyAdmin.
Creating the Temporary Directory
phpMyAdmin uses a temporary directory for some operations.
sudo mkdir /usr/share/phpmyadmin/tmp
sudo chmod 777 /usr/share/phpmyadmin/tmp
Creating the phpMyAdmin Configuration File
cd /usr/share/phpmyadmin
sudo cp config.sample.inc.php config.inc.php
Generating blowfish_secret Key
phpMyAdmin uses a key for cookie security.
openssl rand -base64 32
Add the generated key to config.inc.php:
$cfg['blowfish_secret'] = 'BURAYA_OLUŞTURULAN_ANAHTARI_YAPIŞTIR';
Creating phpMyAdmin Meta Tables
phpMyAdmin uses special tables for some advanced features.
sudo mysql < /usr/share/phpmyadmin/sql/create_tables.sql
Creating phpMyAdmin Administrative User
Enter the MariaDB console:
sudo mysql
Then run the following SQL commands:
CREATE USER 'pma'@'localhost' IDENTIFIED BY 'güçlü_sifre';
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Apache Configuration
phpMyAdmin Apache Configuration
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
File content:
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
<Directory /usr/share/phpmyadmin/setup>
Require local
</Directory>
PHP Security Settings (open_basedir)
sudo nano /etc/php/7.3/apache2/conf.d/phpmyadmin-security.ini
open_basedir = /usr/share/phpmyadmin/:/usr/share/phpmyadmin/tmp/:/usr/share/phpmyadmin/vendor/
upload_tmp_dir = /usr/share/phpmyadmin/tmp
session.save_path = /usr/share/phpmyadmin/tmp
Restart the Apache service:
sudo systemctl restart apache2
Enabling Apache Configuration
sudo a2enconf phpmyadmin
sudo systemctl reload apache2
.htaccess Protection (Optional)
You can protect phpMyAdmin access with an additional password.
sudo nano /usr/share/phpmyadmin/.htaccess
AuthType Basic
AuthName "phpMyAdmin"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
Create the password file:
sudo mkdir /etc/phpmyadmin
sudo htpasswd -c /etc/phpmyadmin/.htpasswd admin
Accessing phpMyAdmin
Visit the following address from the browser:
```http://SUNUCU-IP/phpmyadmin`` `
Frequently Asked Questions
Why didn't we use apt install phpmyadmin?
The version in Debian 10 repositories may be out of date. For this reason, installation from the source code was preferred for the most current version.
What happens if I lose the blowfish_secret key?
You can create a new key. Old session cookies become invalid, but the system continues to work.
Can MySQL be used instead of MariaDB?
Yes. phpMyAdmin is compatible with both MariaDB and MySQL.
I'm getting a 404 Not Found error!
It is usually caused by Apache configuration not being enabled.
sudo a2enconf phpmyadmin
sudo systemctl reload apache2
Result
phpMyAdmin on Debian 10 in this guide:
Built from source code Configured with Apache Integrated with MariaDB Security settings applied
Now you can easily manage your databases via the web interface.
You can quickly implement this setup on GenixNode servers.

