Upgrade/Install phpMyAdmin on Debian

Rule #1: “Do not fix, if it’s not broken”
I’ve had version phpMyAdmin 5.0.2 since 2020 without any problem (PHP 7.+, 8.0) until I decided to look at PHP 8.1. Number of “Deprecated” messages from twig/twig package just killed the system, and Composer failed to update outdated packages.
Rule #2 extends #1: If you do not have a VERY GOOD REASON to use PHP 8.1, stay with the current version

Download “the latest, the greatest” release from official website, and “unzip” it on the local drive.

tar xvf phpMyAdmin-*.tar.gz

Upgrade (tested from 5.0.2 to 5.2.0)

Save existing configuration file

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

Remove existing installation

sudo rm -R /usr/share/phpmyadmin

Move new files

sudo mv phpMyAdmin-*/ /usr/share/phpmyadmin

Restore configuration file

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

Fresh installation

sudo mv phpMyAdmin-*/ /usr/share/phpmyadmin
sudo mkdir -p /var/lib/phpmyadmin/tmp
sudo mkdir /etc/phpmyadmin/
sudo chown -R www-data:www-data /var/lib/phpmyadmin
sudo cp /usr/share/phpmyadmin/config.sample.inc.php  /usr/share/phpmyadmin/config.inc.php
# add secrety phrase
sudo nano /usr/share/phpmyadmin/config.inc.php

Generate phpMyAdmin blowfish secret phrase

$cfg['blowfish_secret'] = 'H2OxcGXxflSd8JwrwVlh6KW6s2rER63i';
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
# congig apache
sudo nano /etc/apache2/conf-enabled/phpmyadmin.conf
Alias /phpmyadmin /usr/share/phpmyadmin

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

# Authorize for setup

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

# Disallow web access 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>
sudo service apache2 restart

sudo mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 41
Server version: 10.3.23-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'localhost' WITH GRANT OPTION;
or
MariaDB [(none)]> GRANT ALL PRIVILEGES ON 'database_name'.* TO 'user_name'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES -- optional;
MariaDB [(none)]> \q
Bye

Source: How To Install phpMyAdmin on Debian 11/Debian 10

Leave a Reply

Your email address will not be published.

Yandex.Metrica