I have multiple webservers running a debian jessie LAMP installation. I do not want to install phpmyadmin on all of them so a central installation is necessary. I chose to set up a ssh tunnel to each server that is opened at boot and uses autossh for persistance. phpmyadmin is then configured with the additional servers to enable simple connectivity.
To /etc/rc.local I’ve added a line for each server (with an increasing local port, here 3307) for the persistent tunnel.
/usr/bin/autossh -M 0 -q -f -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -L 3307:localhost:3306 root@domain.tld. |
I also added a corresponding section to /etc/phpmyadmin/config.inc.php at the end of the server section.
$cfg['Servers'][$i]['verbose'] = 'domain.tld'; $cfg['Servers'][$i]['host'] = '127.0.0.1'; $cfg['Servers'][$i]['port'] = '3307'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['compress'] = FALSE; $cfg['Servers'][$i]['auth_type'] = 'cookie'; $i++; |
In this way I have set up a centralized phpmyadmin without opening up any additional ports on any server.