phpMyAdmin is a free and open-source web-based database management tool written in PHP. It provides a graphical web interface for users to manage MySQL or MariaDB databases. Installing phpMyAdmin in Debian 10 is not easy when compared to Ubuntu and its derivates, because unlike ubuntu Debian 10 hasn't included phpMyAdmin in the software repository. So we have to install it manually.
Updating APT Package Repository Cache:
First, update the APT package repository cache with the following commandsudo apt update
Installing and Configuring MariaDB:
Now, install MariaDB server and client packages from the official package repository of Debian with the following command:sudo apt install mariadb-server mariadb-client
Set a root password for MariaDB:
sudo mysql_secure_installation
Installing Apache Web Server, PHP, and Required PHP Libraries:
Install Apache 2 web server, PHP, and all the required PHP libraries with the following commandsudo apt install -y unzip wget gnupg git curl vim tmux apache2 mariadb-server php libapache2-mod-php php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,cli,fpm,opcache,xml,curl,intl,xsl,soap,json,apcu,imap,xmlrpc}
Downloading phpMyAdmin:
You can download the latest phpMyAdmin from the official website of phpMyAdmin. Once the page loads, click on the Download and copy the link locationsudo wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip
Just List, whether phpMyAdmin zip file has been downloaded to the home directory
ls
Now, extract the phpMyAdmin archive in the /opt directory with the following command:
sudo unzip phpMyAdmin-5.2.1-all-languages.zip -d /opt
To see the phpMyAdmin directory is created in the /opt directory.
ls -lh /opt
For the sake of simplicity, rename the directory to just phpMyAdmin/ with the following command:
sudo mv -v /opt/phpMyAdmin-5.2.1-all-languages /opt/phpMyAdmin
Now, change the owner and group of the /opt/phpMyAdmin directory and all the contents of the directory to www-data.
sudo chown -Rfv www-data:www-data /opt/phpMyAdmin
The owner and group of the /opt/phpMyAdmin directory and contents of the directory should be changed to www-data.
Configuring Apache for phpMyAdmin:
Now, we have to configure the Apache webserver in order to use phpMyAdmin. I am going to configure phpMyAdmin on port 80 in this article. ( You can assign a different port if you want)First, create a new site configuration file for phpMyAdmin with the following command:
sudo nano /etc/apache2/sites-available/phpmyadmin.conf
Now, add the following lines to the PHPMyAdmin.conf file.
<VirtualHost *:8002>
ServerAdmin webmaster@localhost
DocumentRoot /opt/phpMyAdmin
<Directory /opt/phpMyAdmin>
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_phpmyadmin.log
CustomLog ${APACHE_LOG_DIR}/access_phpmyadmin.log combined
</VirtualHost>
save the file
If you are assigning ports like 8002, you have to tell the Apache webserver to listen to port 8002.
To do that, edit the /etc/apache2/ports.conf configuration file with the following command:
sudo nano /etc/apache2/ports.conf
Now, add the line “Listen 8002” and save the file.
Enable the phpMyAdmin site that we’ve just configured with the following command:
sudo a2ensite phpmyadmin.conf
Restart the Apache webserver with the following command:
sudo systemctl reload apache2 && sudo systemctl restart apache2
Accessing phpMyAdmin:
You should be able to access phpMyAdmin on port with default port 80 or the port you have assigned like 8000.From a browser, visit http://localhost:8002 and you should see the login page of phpMyAdmin with MariaDB root user and root password.
Fix The configuration file now needs a secret passphrase (blowfish_secret)
You’ll see this error after every installation of PHPMyAdmin. To resolve this issue, just open config.inc.php ( or rename config.sample.inc.php to config.inc.php if you haven’t done so yet ) and change this line
Navigate to phpMyAdmin directory
Navigate to phpMyAdmin directory
cd /opt/phpMyAdmin/
Rename config.sample.inc.php to config.inc.php
sudo mv config.sample.inc.php config.inc.php
Replace the red line to the blue line in config.php
sudo vim /opt/phpMyAdmin/config.inc.php
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
to
$cfg['blowfish_secret'] = '0a;L}L260V/5NLeOWQg7mZKb[B7EGQZH';
Create an admin user to access MySQL/MariaDB from PHPMyAdmin
Login to MySQL/MariaDB shell
sudo mysql -uroot -p
(provide root password)
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin123';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit;
Reference: