Skip to main content

Dedicated Server: Installation of phpMyAdmin

This guide was created with the following products:

(Details may vary with products from different providers but the main concepts remain the same)

Introduction

phpMyAdmin is a free, web-based tool for managing MySQL and MariaDB databases. It provides a user-friendly interface that allows users to create, edit, manage and delete databases without having to enter SQL commands manually.

Preparation

First, you should check whether the server is up to date. To do this, the update command is executed:

sudo apt update

If the server has found new updates/packages, they can be installed with the upgrade command.

sudo apt upgrade -y

The server is now up to date.

info

If "sudo" is not found, this can be installed with the following command:

apt install sudo -y

Installation

First, the installation directory is selected in which phpMyAdmin is to be installed. This is done with the following command:

cd /usr/share

Then, the latest phpMyAdmin version is downloaded to the installation directory using wget:

wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -O phpmyadmin.zip
info

If "wget" is not found, this can be installed with the following command:

sudo apt install wget -y

As soon as the download is complete, the ZIP file can be extracted using the following command:

unzip phpmyadmin.zip
info

If "unzip" is not found, this can be installed with the following command:

sudo apt install unzip -y

Now, the extracted archive can be renamed to a simpler name:

mv phpMyAdmin-*-all-languages phpmyadmin

After this is done, the original ZIP file can be removed and the necessary rights for the phpMyAdmin directory can be set by using this:

rm phpmyadmin.zip; chmod -R 0755 phpmyadmin

Creating Apache2 phpMyAdmin-Config

The Apache2-phpMyAdmin-Config is created with the following command:

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

The empty Apache2-phpMyAdmin-Config must now be equipped with the following content:

# phpMyAdmin Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
Options SymLinksIfOwnerMatch
DirectoryIndex index.php
</Directory>

# Disallow web access for security 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>

If the Apache2-phpMyAdmin-Config is now filled with the content, it can be saved and closed with *** CTRL + X ***, then press the *** Y key *** and with *** Enter *** to confirm. The newly created Apache2-phpMyAdmin-Config must be activated/read in by the Apache2 server:

a2enconf phpmyadmin

The Apache2 server must then be reloaded:

systemctl reload apache2

Creating temporary directory for phpMyAdmin

For phpMyAdmin to work properly, the following directory must be created:

mkdir /usr/share/phpmyadmin/tmp/

The directory just created still needs the correct rights, here is how to do this:

chown -R www-data:www-data /usr/share/phpmyadmin/tmp/

The phpMyAdmin installation is finished.

The phpMyAdmin web interface can now be opened via browser with/phpmyadmin, e.g. 123.123.123.123/phpmyadmin