9.5 C
Texas
angeloma
Senior Writer and partner

How to install PHPMyAdmin on Debian 11

Hello, friends. In this post, we will help you to install the latest stable version of PHPMyAdmin on Debian 11.

If there is a tool that has helped in the management of MySQL / MariaDB data is PHPMyAdmin both professionals and students or even enthusiasts.

So, what is PHPMyAdmin?

According to the project website,

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. Frequently used operations (managing databases, tables, columns, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still can directly execute any SQL statement.

- Advertisement -

Therefore, with PHPMyAdmin we can quickly query our data and other options quickly and easily. In addition to this, we are talking about an open-source project with which we can examine its source code and even modify it.

Another advantage of using PHPMyAdmin is that as it is a project created with PHP, the only thing we need is an operating system with a web server installed. From there, we can then access it with a web device such as a computer, tablet, or mobile phone.

So, let’s get started.

Install PHPMyAdmin on Debian 11

By default, it is included in the official Debian 11 repositories. So installing it is very easy to do. The problem is that the versions included in the repositories are not always the most up-to-date.

So in this post, we’ll go through the whole process to get the latest stable version published on the PHPMyAdmin website.

Install LAMP on Debian 11

Since this is a web application, then it is necessary to have our computer working as a web server. So, we need to install LAMP on Debian 11

For that, you have to install first Apache on Debian 11 and then MariaDB on Debian 11. With our posts, you will have no problem doing that.

Also, it is necessary to install some PHP modules such as

php libapache2-mod-php php-mysql php-mysql php-mbstring php-xml php-zip

Once we have LAMP fully installed, we can continue.

Downloading and installing the latest version of PHPMyAdmin

At the time of writing this post, the latest stable version of PHPMyAdmin is 5.1.1 in the future this will change. So to keep it working, in the commands replace 5.1.1 with the updated version number.

Now, from the /tmp/ folder download PHPMyAdmin with the command wget.

cd /tmp/
wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.tar.gz

Then unzip it and move it to another location. In this case, I will move it to /usr/share/phpmyadmin.

sudo mv phpMyAdmin-5.1.1-all-languages /usr/share/phpmyadmin

Now create a tmp folder dedicated to PHPMyAdmin. Then make Apache the owner of it.

sudo mkdir -p /var/lib/phpmyadmin/tmp
sudo chown -R www-data:www-data /var/lib/phpmyadmin

Also, create a folder dedicated to the configuration:

sudo mkdir /etc/phpmyadmin/

Enable the PHPMyAdmin configuration by copying the sample with the configuration name that the program will recognize.

sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php

This file needs to be edited to make two modifications.

sudo nano /usr/share/phpmyadmin/config.inc.php

The first is to define a passphrase that will help us to increase security.

$cfg['blowfish_secret'] = '[passphrase]'; 

The second is to set the path to the temporary folder we created for PHPMyAdmin. You can add this line.

$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';

Save your changes and close the editor.

Now you need to add a recommended Apache configuration for ideal access to PHPMyAdmin.

So, Create the file

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

And add the following:

Alias /phpmyadmin /usr/share/phpmyadmin
ServerName your-domain

<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>

<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>

Save the changes and close the editor.

Now enable the rewrite module and check the service status for an error.

sudo a2enmod rewrite
sudo systemctl restart apache2
sudo systemctl status apache2

Optionally, but recommended, you can secure access to PHPMyAdmin by installing Let’s Encrypt certificates.

So, install Certbot and the Apache plugin.

sudo apt install certbot python3-certbot-apache

And generate the certificates as follows

sudo certbot --apache -d [your-domain]

Then, follow the interactive instructions of the tool. There you will have to define your email address and the installation will be done.

Then, restart Apache.

sudo systemctl restart apache2

Now you can access using your favorite web browser at https://your-server/phpmyadmin/ and you will see the login screen.

1.- PHPMyAdmin on Debian 11
1.- PHPMyAdmin on Debian 11

So, enjoy it.

Conclusion

PHPMyAdmin is a sophisticated tool that allows us to manage a MariaDB instance without much trouble. It can be useful to save a lot of time in viewing the data and the many options we have to work with.

With this post, you learned how to install the latest stable version without major problems having LAMP as a base.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article