How-to install phpmyamdin on Debian

for me phpmyamdin is a really great tool for to manage mysql from the web. It’s always the first thing I install just after setting up mysql

this tutorial will show you how to install phpmyamdin on debian (I tried on debian 13, but it’s the same for other Debian versions)

1. Update your system

it’s always good to update your system before doing every installation

sudo apt update && sudo apt upgrade -y

2. Install required packages

phpmyadmin is a tool written in php so we need to install some dependencies. Also we need an http server like Apache and Mariadb (alias mysql)

sudo apt install apache2 mariadb-server php php-mbstring php-zip php-gd php-json php-curl php-mysql php-xml php-cli php-common php-intl php-fpm unzip -y

3. Enable PHP extensions

sudo phpenmod mbstring
sudo systemctl restart apache2

4. Install phpMyAdmin

Debian no longer ships phpMyAdmin in its official repositories, so we need to install it manually:

Download latest phpMyAdmin

cd /usr/share
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
sudo tar xvf phpMyAdmin-latest-all-languages.tar.gz
sudo mv phpMyAdmin-*-all-languages phpmyadmin
sudo rm phpMyAdmin-latest-all-languages.tar.gz

5. Create phpMyAdmin configuration directory

sudo mkdir /usr/share/phpmyadmin/tmp
sudo chmod 777 /usr/share/phpmyadmin/tmp

6. Configure Apache

Create config file for the virtual host of phpmyamdin:

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Paste this into phpmyadmin.conf (you can open the file with nano):

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php
    AllowOverride All
    Require all granted
</Directory>

<Directory /usr/share/phpmyadmin/setup>
    Require local
</Directory>

Enable it:

sudo a2enconf phpmyadmin
sudo systemctl reload apache2

7. Create the user for phpmyadmin

Then inside MariaDB create a local user:

CREATE USER 'pma'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'pma'@'localhost';
FLUSH PRIVILEGES;
EXIT;

8. Access phpMyAdmin

Open in browser:

http://your-server-ip/phpmyadmin

Log in using your MySQL/MariaDB user and enjoy it


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *