wreckkage
4/2/2017 - 6:22 AM

Provision script for vagrant - Apache 2.4 - PHP 5.6 - MySQL 5.7 - Composer - NodeJS v6 - Bower

Provision script for vagrant

  • Apache 2.4
  • PHP 5.6
  • MySQL 5.7
  • Composer
  • NodeJS v6
  • Bower
echo "Starting provisioning script..."

# install dependencies
sudo apt-get install -y \
curl \ 
zip \
unzip \
git \
software-properties-common \
apache2

# add php repository
sudo add-apt-repository -y ppa:ondrej/php >> /vagrant/vm_build.log 2>&1

# fetch updates and install php modules
sudo apt-get update && sudo apt-get dist-upgrade >> /vagrant/vm_build.log 2>&1
sudo apt-get install -y php5.6 >> /vagrant/vm_build.log 2>&1
sudo apt-get install -y php5.6-fpm \
php5.6-mcrypt \
php5.6-gd \
php5.6-mysql \
php5.6-pgsql \
php5.6-imap \
php-memcached \
php5.6-mbstring \
php5.6-xml \
php5.6-curl \
php5.6-zip >> /vagrant/vm_build.log 2>&1

sudo a2enmod proxy_fcgi setenvif headers rewrite >> /vagrant/vm_build.log 2>&1
sudo a2enconf php5.6-fpm >> /vagrant/vm_build.log 2>&1
sudo service apache2 restart >> /vagrant/vm_build.log 2>&1
sudo service php5.6-fpm restart >> /vagrant/vm_build.log 2>&1

# clean-up
sudo apt-get remove -y --purge software-properties-common && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* >> /vagrant/vm_build.log 2>&1

# install mysql
# MySQL setup for development purposes ONLY
echo -e "\n--- Install MySQL specific packages and settings ---\n"

# variables
DBHOST=localhost
DBNAME=test_db
DBUSER=developer
DBPASSWD=develop5000

sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $DBPASSWD"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DBPASSWD"

sudo apt-get -y install mysql-server >> /vagrant/vm_build.log 2>&1

echo -e "\n--- Setting up our MySQL user and db ---\n"
mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME" >> /vagrant/vm_build.log 2>&1
mysql -uroot -p$DBPASSWD -e "grant all privileges on $DBNAME.* to '$DBUSER'@'localhost' identified by '$DBPASSWD'" > /vagrant/vm_build.log 2>&1

echo -e "\n--- Updating packages list ---\n"
sudo apt-get -qq update

# install composer
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer >> /vagrant/vm_build.log 2>&1
composer >> /vagrant/vm_build.log 2>&1

# install nodejs
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - >> /vagrant/vm_build.log 2>&1
sudo apt-get install nodejs >> /vagrant/vm_build.log 2>&1

# install bower
sudo npm install -g bower >> /vagrant/vm_build.log 2>&1