Last active
August 15, 2020 17:22
-
-
Save gggordon/ae4b0a60613e3964b8838b4a630d9b1c to your computer and use it in GitHub Desktop.
Ubuntu 16.0.4 Unattended LAMP installation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Copyright gggordon 2015 | |
# License @MIT | |
# adapted from https://gist.github.com/gggordon/4b068ee89cf92a82d078 | |
set -e | |
MYSQL_ROOT_PASS='password' | |
PHPMYADMIN_DIR='phpmyadmin' | |
#Install Apache2, PHP5, MySQL if they do not exist | |
if [ ! -f /etc/apache2/apache2.conf ]; | |
then | |
#Install Apache2 and PHP5 | |
apt-get --assume-yes install apache2 apache2-utils | |
add-apt-repository --yes ppa:ondrej/php | |
apt-get --assume-yes update | |
apt-get --assume-yes install php7.1 | |
apt-get --assume-yes install libapache2-mod-php7.1 php7.1-fpm php7.1-common php7.1-cli php-pear php7.1-curl php7.1-gd php7.1-gmp php7.1-intl php7.1-imap php7.1-json php7.1-ldap php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-ps php7.1-readline php7.1-tidy php7.1-xmlrpc php7.1-xsl | |
service apache2 restart | |
#Enable necessary apache2 mods for per-user directories | |
#a2enmod php5 | |
#a2enmod userdir | |
#Enable php access in user directories | |
#cp /etc/apache2/mods-enabled/php5.conf /etc/apache2/mods-enabled/php5.conf_old | |
#sed -i '/<IfModule mod_userdir.c>/,/<\/IfModule>/s/^/#/' /etc/apache2/mods-enabled/php5.conf | |
#Custom user directories specified in userdir.conf | |
#cp /etc/apache2/mods-available/userdir.conf /etc/apache2/mods-available/userdir.conf_old | |
#cp tasks/LAMP/userdir.conf /etc/apache2/mods-available/userdir.conf | |
#restart service | |
service apache2 restart | |
#Install MySQL with preconfigured password | |
echo "mysql-server mysql-server/root_password password $MYSQL_ROOT_PASS" | debconf-set-selections | |
echo "mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASS" | debconf-set-selections | |
apt-get --assume-yes install mysql-server | |
fi | |
#Install phpmyadmin | |
if [ ! -f /etc/phpmyadmin/config.inc.php ]; | |
then | |
#Get random data for app password | |
AUTOGENERATED_PASS=`tr -dc A-Za-z0-9 < /dev/urandom | head -c 64` | |
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/mysql/admin-user string root" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/mysql/admin-pass password $MYSQL_ROOT_PASS" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/mysql/app-pass password $AUTOGENERATED_PASS" |debconf-set-selections | |
echo "phpmyadmin phpmyadmin/app-password-confirm password $AUTOGENERATED_PASS" | debconf-set-selections | |
apt-get --assume-yes install phpmyadmin | |
#Change phpMyAdmin directory | |
sed -i -r "s:(Alias /).*(/usr/share/phpmyadmin):\1$PHPMYADMIN_DIR \2:" /etc/phpmyadmin/apache.conf | |
#php5enmod mcrypt # Needs to be activated manually (that's an issue for Ubuntu 14.04) | |
service apache2 reload | |
fi |
You may want to add
sudo apt-get install php7.2-zip
sudo apt-get --assume-yes install php7.3
sudo apt-get --assume-yes install libapache2-mod-php7.3 php7.3-fpm php7.3-common php7.3-cli php-pear php7.3-curl php7.3-gd php7.3-gmp php7.3-intl php7.3-imap php7.3-json php7.3-ldap php7.3-mbstring php7.3-mcrypt php7.3-mysql php7.3-ps php7.3-readline php7.3-tidy php7.3-xmlrpc php7.3-xsl php7.3-zip
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo apt-get --assume-yes install libapache2-mod-php7.2 php7.2-fpm php7.2-common php7.2-cli php-pear php7.2-curl php7.2-gd php7.2-gmp php7.2-intl php7.2-imap php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-readline php7.2-tidy php7.2-xmlrpc php7.2-xsl