5

Referencing this tutorial: https://www.liquidweb.com/kb/how-to-install-and-configure-phpmyadmin-on-ubuntu-14-04/ for installing PHP-Admin, after installing the package, on "Step 2: Basic Configuration" some questions need to be filled out by the user.

Is it possible to complete these configurations entirely via Shell Script from the command line?

chicks
  • 3,915
  • 10
  • 29
  • 37
Rodrigo
  • 51

2 Answers2

6

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
Esa Jokinen
  • 52,963
  • 3
  • 95
  • 151
0

I hope this script helps. I am still working out how to automate apache configuration

export DEBIAN_FRONTEND="noninteractive"
sudo apt update
sudo apt install -yq phpmyadmin

Set the MySQL administrative user's password

sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-user string root" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $MYSQL_ROOT_PASSWORD" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $MYSQL_ROOT_PASSWORD" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2"

sudo dpkg-reconfigure -f noninteractive phpmyadmin

echo "Include /etc/phpmyadmin/apache.conf" >> /etc/apache2/apache2.conf

sudo service apache2 restart echo "Apache service restarted"