PhpMyAdmin/Installation
PHPMyAdmin Database Administration Tool
Since Debian 10, PHPMyAdmin is not available as .deb package anymore. Therefore we will install it from source.
Create folders for PHPMyadmin:
mkdir /usr/share/phpmyadmin mkdir /etc/phpmyadmin mkdir -p /var/lib/phpmyadmin/tmp chown -R www-data:www-data /var/lib/phpmyadmin touch /etc/phpmyadmin/htpasswd.setup
Go to the /tmp directory and download the PHPMyAdmin sources:
cd /tmp wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz
Unpack the downloaded archive file and move the files to the /usr/share/phpmyadmin folder and clean up the /tmp directory.
tar xfz phpMyAdmin-4.9.0.1-all-languages.tar.gz mv phpMyAdmin-4.9.0.1-all-languages/* /usr/share/phpmyadmin/ rm phpMyAdmin-4.9.0.1-all-languages.tar.gz rm -rf phpMyAdmin-4.9.0.1-all-languages
Create a new config file for PHPMyaAdmin based on the provided sample file:
cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
Open the config file with nano editor:
nano /usr/share/phpmyadmin/config.inc.php
Set a secure password (blowfish secret) which must be 32 chars long:
$cfg['blowfish_secret'] = 'bD3e6wva9fnd93jVsb7SDgeiBCd452Dh'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Don't use my example blowfish secret, set your own one!
Then add a line to set the directory which PHPMyAdmin shall use to store temporary files:
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
Next, we create the Apache configuration file for PHPMyAdmin by opening a new file in nano editor:
nano /etc/apache2/conf-available/phpmyadmin.conf
Paste the following config into the file and save it.
# phpMyAdmin default Apache configuration Alias /phpmyadmin /usr/share/phpmyadmin <Directory /usr/share/phpmyadmin> Options FollowSymLinks DirectoryIndex index.php <IfModule mod_php7.c> AddType application/x-httpd-php .php php_flag magic_quotes_gpc Off php_flag track_vars On php_flag register_globals Off php_value include_path . </IfModule> </Directory> # Authorize for setup <Directory /usr/share/phpmyadmin/setup> <IfModule mod_authn_file.c> AuthType Basic AuthName "phpMyAdmin Setup" AuthUserFile /etc/phpmyadmin/htpasswd.setup </IfModule> Require valid-user </Directory>
- Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries> Order Deny,Allow Deny from All </Directory> <Directory /usr/share/phpmyadmin/setup/lib> Order Deny,Allow Deny from All </Directory>
Activate the configuration and restart Apache.
a2enconf phpmyadmin systemctl restart apache2
In the next step, we will configure the phpMyadmin configuration store (database).
Log into MariaDB as root user:
mysql -u root -p
In the MariaDB shell, create a new database for PHPMyAdmin:
MariaDB [(none)]> CREATE DATABASE phpmyadmin;
Then create a new user:
MariaDB [(none)]> CREATE USER 'pma'@'localhost' IDENTIFIED BY 'mypassword';
Replace the word mypassword with a secure password of your choice in the commands above and below, use the same password both times. Then grant the user access to this database and reload database permissions.
MariaDB [(none)]> GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT;
Finally, load the SQL tables into the database:
mysql -u root -p phpmyadmin < /usr/share/phpmyadmin/sql/create_tables.sql
Enter the MariaDB root password on request.
All we have to do now is to set the phpmyadmin user details in the configuration file. Open the file in nano editor again:
nano /usr/share/phpmyadmin/config.inc.php
Scroll down until you see the lines below and edit them:
/* User used to manipulate with storage */ $cfg['Servers'][$i]['controlhost'] = 'localhost'; $cfg['Servers'][$i]['controlport'] = ; $cfg['Servers'][$i]['controluser'] = 'pma'; $cfg['Servers'][$i]['controlpass'] = 'mypassword'; /* Storage database and tables */ $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; $cfg['Servers'][$i]['relation'] = 'pma__relation'; $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; $cfg['Servers'][$i]['history'] = 'pma__history'; $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; $cfg['Servers'][$i]['recent'] = 'pma__recent'; $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; $cfg['Servers'][$i]['users'] = 'pma__users'; $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
I've marked the lines in red which I've edited. Replace mypassword with the password that you've chosen for the phpmyadmin user. Note that the // in front of the lines have been removed as well!