Last active
November 20, 2018 07:20
-
-
Save LPMAXI/5a598b494b7099c5581358bdd3d720f3 to your computer and use it in GitHub Desktop.
Provision script for Ubuntu 16.04 LTS - Apache, PHP7, MySql, Git, Composer, NodeJS
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 | |
# | |
# Provision script for Ubuntu 14.06 LTS | |
# ------------ | |
# | |
# Inspired and modified from: https://gist.github.com/maoosi/d3a4c5670d4f014fe0082f88e48e89af | |
# Includes: Apache, PHP7, MySql, Git, Composer, NodeJS | |
# | |
echo "\n--- Installing now... ---\n" | |
echo "\n>> Please enter a name for the database:\n" | |
read DBNAME | |
echo "\n>> Please enter an username for accessing the database:\n" | |
read DBUSER | |
echo "\n>> Please enter a password for your database:\n" | |
read DBPASSWD | |
echo "\n>> Create new user\n" | |
echo "\n>> Enter username" | |
read USERNAME | |
echo "\n>> Enter password" | |
read PASSWORD | |
sudo useradd -m -g www-data $USERNAME -s /bin/bash | |
echo $USERNAME:$PASSWORD | chpasswd | |
echo "\n>> Adding user to sudo group" | |
usermod -aG sudo $USERNAME | |
echo "\n\n--- Updating packages list ---\n" | |
sudo apt-get -qq update | |
echo "\n--- Installing Apache2 ---\n" | |
sudo apt-get -y install apache2 > /dev/null 2>&1 | |
echo "\n--- Installing PHP 7.3 ---\n" | |
sudo apt-get install software-properties-common > /dev/null 2>&1 | |
sudo add-apt-repository ppa:ondrej/php > /dev/null 2>&1 | |
sudo apt-get update > /dev/null 2>&1 | |
sudo apt-get install php7.3 > /dev/null 2>&1 | |
php -v | |
echo "\n--- Installing PHP packages ---\n" | |
sudo apt-get install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml > /dev/null 2>&1 | |
echo "\n--- Installing sendmail ---\n" | |
sudo sudo apt-get -y install sendmail | |
echo "\n--- Installing MySql ---\n" | |
echo "mysql-server mysql-server/root_password password $DBPASSWD" | debconf-set-selections | |
echo "mysql-server mysql-server/root_password_again password $DBPASSWD" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/app-password-confirm password $DBPASSWD" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/mysql/admin-pass password $DBPASSWD" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/mysql/app-pass password $DBPASSWD" | debconf-set-selections | |
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect none" | debconf-set-selections | |
sudo apt-get -y install mysql-server > /dev/null 2>&1 | |
#sudo mysql_install_db | |
#sudo mysql_secure_installation | |
##echo "\n--- Setting up our MySQL user and db ---\n" | |
##mysql -uroot -p$DBPASSWD "CREATE DATABASE $DBNAME" | |
##mysql -uroot -p$DBPASSWD "grant all privileges on $DBNAME.* to '$DBUSER'@'localhost' identified by '$DBPASSWD'" | |
echo "\n--- Installing Git ---\n" | |
sudo apt-get -y install git > /dev/null 2>&1 | |
echo "\n--- Updating packages list ---\n" | |
sudo apt-get -qq update | |
echo "\n--- Enabling mod-rewrite ---\n" | |
a2enmod rewrite > /dev/null 2>&1 | |
echo "\n--- Setting up our DirectoryIndex specification ---\n" | |
cat > /etc/apache2/mods-enabled/dir.conf <<EOF | |
<IfModule mod_dir.c> | |
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm | |
</IfModule> | |
EOF | |
echo "\n--- Setting up permissions ---" | |
sudo usermod $USERNAME -g www-data | |
sudo chown -R www-data:www-data /var/www | |
sudo chmod -R g+rwX /var/www | |
echo "\n--- Restarting Apache ---\n" | |
sudo service apache2 restart > /dev/null 2>&1 | |
echo "\n--- Installing Composer ---\n" | |
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer | |
echo "\n--- Installing NodeJS and NPM ---\n" | |
apt-get -y install nodejs > /dev/null 2>&1 | |
curl --silent https://npmjs.org/install.sh | sh > /dev/null 2>&1 | |
echo "\n--- Adding new bash commands ---\n" | |
cat >> ~/.bashrc <<EOF | |
alias cls='clear' | |
EOF | |
echo "\n--- Installation done ! ---\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment