Basically the first thing to do is skipping any interactive post-install configuration steps.
export DEBIAN_FRONTEND=noninteractive
apt-get -yq install phpmyadmin
This will skip all the questions made by dpkg-preconfigure
.
Then, you need to do configuration manually i.e. automate it by yourself by making your script to either create or copy configuration. The local configuration file is in /etc/phpmyadmin/config.inc.php
and you can find some configuration examples in /usr/share/doc/phpmyadmin/examples/
. For security, passwords should be included from a separate file with permissions -rw-r----- root www-data
.
The dpkg-reconfigure phpmyadmin
reads and writes from /etc/dbconfig-common/phpmyadmin.conf
. Your script could be something like this:
export DEBIAN_FRONTEND=noninteractive
apt-get -yq install phpmyadmin
cp /path/to/preconfigured-phpmyadmin.conf /etc/dbconfig-common/phpmyadmin.conf
dpkg-reconfigure --frontend=noninteractive phpmyadmin