Page 1 of 1

Come installo phpmyadmin su una vps dove c'è mariadb che gira in un container pterodactyl?

Posted: Wednesday 17 June 2026, 13:33
by Matteo
Installa Apache e PHP

Code: Select all

apt update

apt install -y \
apache2 \
php \
php-mysql \
php-mbstring \
php-zip \
php-gd \
php-json \
php-curl \
php-xml \
php-intl \
unzip wget

Code: Select all

systemctl restart apache2
Scarica phpMyAdmin

Code: Select all

cd /var/www/html

wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

tar xzf phpMyAdmin-latest-all-languages.tar.gz

mv phpMyAdmin-* phpmyadmin

rm -f phpMyAdmin-latest-all-languages.tar.gz
Configura phpMyAdmin

Code: Select all

cd /var/www/html/phpmyadmin

cp config.sample.inc.php config.inc.php
Genera una chiave Blowfish:

Code: Select all

openssl rand -base64 32

Code: Select all

nano config.inc.php
e inserisci la chiave generata:

Code: Select all

$cfg['blowfish_secret'] = 'CHIAVE_GENERATA';
Permessi

Code: Select all

chown -R www-data:www-data /var/www/html/phpmyadmin
Possibili errori, la cartella esiste già: phpMyAdmin-5.2.3-all-languages

Code: Select all

mv phpMyAdmin-5.2.3-all-languages phpmyadmin
Creare database

da dentro il container pterodactyl:

Code: Select all

CREATE DATABASE mio_database CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Creare Utente

Code: Select all

CREATE USER 'mio_utente'@'%' IDENTIFIED BY 'PasswordMoltoSicura';
Assegnare permessi

Code: Select all

GRANT ALL PRIVILEGES ON mio_database.* TO 'mio_utente'@'%';

FLUSH PRIVILEGES;

Code: Select all

EXIT;
Importare il backup

mettere il file .sql nei files del container

Seleziona il database

Code: Select all

USE nome_database;
Importa il file:

Code: Select all

SOURCE /home/container/backup.sql;
Modifica config.php di phpMyAdmin

Code: Select all

nano /var/www/html/phpmyadmin/config.inc.php
Trova questa sezione:

Code: Select all

$cfg['Servers'][$i]['host'] = 'localhost';
Cambiala così:

Code: Select all

$cfg['Servers'][$i]['host'] = '127.0.0.1'; 
$cfg['Servers'][$i]['port'] = '3306';
-------------------( oppure IP della VPS al posto di 127.0.0.1)-----------------------

Code: Select all

$cfg['Servers'][$i]['host'] = '162.35.xxx.xxx';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

Code: Select all

systemctl restart apache2
CONFIG AGGIUNTIVA (solo differenze rispetto al vecchio 10.5)

Aggiungi in fondo al tuo .my.cnf esistente:

Code: Select all

# --- Legacy compatibility (come vecchio MariaDB 10.5) ---

character-set-server = utf8
collation-server     = utf8_general_ci

# comportamento transazioni simile al vecchio server
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT

# tuning legacy (non invasivo)
key_buffer_size        = 32M
max_allowed_packet     = 64M
thread_stack           = 256K
thread_cache_size      = 50
table_open_cache       = 4096

# logging stile vecchio
expire_logs_days = 10

# disattiva obbligo SSL (come vecchio server)
require-secure-transport = off


------------------------

2. INSTALLA SOLO PHP PER NGINX (IMPORTANTE)

Se non hai PHP-FPM:

Code: Select all

apt install -y \
php \
php-fpm \
php-mysql \
php-mbstring \
php-zip \
php-gd \
php-curl \
php-xml \
php-intl \
unzip wget openssl
3. INSTALLAZIONE phpMyAdmin (come vuoi tu)

Code: Select all

cd /var/www/html

wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

tar xzf phpMyAdmin-latest-all-languages.tar.gz
Se esiste già:

Code: Select all

mv phpMyAdmin-* phpmyadmin
rimuovi archivio

Code: Select all

rm -f phpMyAdmin-latest-all-languages.tar.gz
4. CONFIGURAZIONE phpMyAdmin

Code: Select all

cd /var/www/html/phpmyadmin

Code: Select all

cp config.sample.inc.php config.inc.php
genera chiave blowfish

Code: Select all

openssl rand -base64 32
modifica config

Code: Select all

nano config.inc.php
trova:

Code: Select all

$cfg['blowfish_secret'] = '';
e inserisci:

Code: Select all

$cfg['blowfish_secret'] = 'CHIAVE_GENERATA';
5. PERMESSI (NGINX STYLE)

Code: Select all

chown -R www-data:www-data /var/www/html/phpmyadmin
6. CONFIG NGINX (OBBLIGATORIO)

Crea file:

Code: Select all

nano /etc/nginx/sites-available/phpmyadmin
CONFIG PRONTA:

Code: Select all

server {
    listen 8081;
    server_name _;

    root /var/www/html/phpmyadmin;
    index index.php index.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
    }
}
ATTIVA SITO

Code: Select all

ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/
RIAVVIA NGINX

Code: Select all

systemctl restart nginx
systemctl restart php8.4-fpm
7. ACCESSO
http://xxx.xxx.xxx.xxx:8081

Metodo 2: usare SOURCE dentro MariaDB

Se vuoi restare nella console MariaDB:

Seleziona il database:

Code: Select all

USE nome_database;
Importa il file:

Code: Select all

SOURCE /home/container/backup.sql;