PhpMyAdmin/Installation

Aus Foxwiki
Version vom 1. August 2024, 10:46 Uhr von Dirkwagner (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

Paketbasiert

Repository

deb http://deb.debian.org/debian bullseye-backports main

Installation

apt install -t bullseye-backports phpmyadmin

You may find other ways on the Wiki for install methods on Ubuntu/Debian

Manuell

Create folders

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

Download

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

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

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 vi editor:

vi /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';

Apache configuration

Next, we create the Apache configuration file for PHPMyAdmin by opening a new file in vi editor:

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

Configure phpMyadmin

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 vi editor again:

vi /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!

Update

  1. Aktuelle phpMyAdmin herunterladen: https://www.phpmyadmin.net/downloads/
  2. Benennen Sie den vorhandenen phpMyAdmin-Ordner um (z. B.  in phpMyAdmin-alt).
  3. Entpacken der heruntergeladene Datei in das gewünschte Verzeichnis (z. B.  phpMyAdmin).
  4. Kopieren Sie config.inc.php aus dem alten Verzeichnis (phpMyAdmin-alt) in das neue (phpMyAdmin).
  5. Überprüfen Sie, ob alles ordnungsgemäß funktioniert.
  6. Entfernen Sie die Sicherung der vorigen Version (phpMyAdmin-alt).

Wenn Sie Ihren MySQL-Server von einer Version früher als 4.1.2 auf Version 5.x oder neuer aktualisiert haben und Sie den phpMyAdmin-Konfigurationsspeicher nutzen, sollten Sie das SQL-Skript sql/upgrade_tables_mysql_4_1_2+.sql ausführen.

Wenn Sie Ihr phpMyAdmin auf 4.3.0 oder neuer von 2.5.0 oder neuer (<= 4.2.x) aktualisiert haben und wenn Sie den phpMyAdmin-Konfigurationsspeicher nutzen, sollten Sie das SQL-Skript sql/upgrade_column_info_4_3_0+.sql ausführen.

Vergessen Sie nicht, den Browsercache zu löschen und die letzte Sitzung zu leeren, indem Sie sich abmelden und danach wieder anmelden.

Links

Intern

  1. PhpMyAdmin

Weblinks

  1. https://docs.phpmyadmin.net/de/latest/
  2. https://de.wikipedia.org/wiki/PhpMyAdmin
  3. https://github.com/phpmyadmin/phpmyadmin/wiki/DebianUbuntu