Provision script for Ubuntu 14.04 LTS - Apache, PHP, MySql, Git, Composer, NodeJS
#! /usr/bin/env bash
#
# Provision script for Ubuntu 14.04 LTS
# ------------
#
# Author: https://github.com/maoosi
# Includes: Apache, PHP, MySql, Git, Composer, NodeJS
#
echo -e "\n--- Installing now... ---\n"
echo -e "\n>> Please enter a name for the database:\n"
read DBNAME
echo -e "\n>> Please enter an username for accessing the database:\n"
read DBUSER
echo -e "\n>> Please enter a password for your database:\n"
read DBPASSWD
echo -e "\n\n--- Updating packages list ---\n"
sudo apt-get -qq update
echo -e "\n--- Installing Apache2 ---\n"
sudo apt-get -y install apache2 > /dev/null 2>&1
echo -e "\n--- Installing PHP5 ---\n"
sudo apt-get -y install php5 libapache2-mod-php5 > /dev/null 2>&1
echo -e "\n--- Installing PHP packages ---\n"
sudo apt-get -y install php5-cli php5-mcrypt php5-curl php5-common php5-json php5-gd php5-imagick php5-mysql php-apc > /dev/null 2>&1
echo -e "\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 -e "\n--- Setting up our MySQL user and db ---\n"
mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME"
mysql -uroot -p$DBPASSWD -e "grant all privileges on $DBNAME.* to '$DBUSER'@'localhost' identified by '$DBPASSWD'"
echo -e "\n--- Installing Git ---\n"
sudo apt-get -y install git > /dev/null 2>&1
echo -e "\n--- Updating packages list ---\n"
sudo apt-get -qq update
echo -e "\n--- Enabling mod-rewrite ---\n"
a2enmod rewrite > /dev/null 2>&1
echo -e "\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 -e "\n--- Restarting Apache ---\n"
sudo service apache2 restart > /dev/null 2>&1
echo -e "\n--- Installing Composer ---\n"
curl --silent https://getcomposer.org/installer | php > /dev/null 2>&1
sudo mv composer.phar /usr/local/bin/composer
echo -e "\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 -e "\n--- Adding new bash commands ---\n"
cat >> ~/.bashrc <<EOF
alias cls='clear'
EOF
echo -e "\n--- Installation done ! ---\n"