Skip to content

Instantly share code, notes, and snippets.

@usm4n
Created March 10, 2014 17:35
Show Gist options
  • Save usm4n/9469910 to your computer and use it in GitHub Desktop.
Save usm4n/9469910 to your computer and use it in GitHub Desktop.
#!/bin/bash
# simple vagrant provisioning script
# installs : apache2, php 5.4 and mysql-server and client
# installs : laravel in /vagrant shared folder
# some coloring in outputs.
COLOR="\033[;35m"
COLOR_RST="\033[0m"
echo -e "${COLOR}---updating system---${COLOR_RST}"
apt-get update
echo -e "${COLOR}---installing some tools: zip,unzip,curl, python-software-properties---${COLOR_RST}"
apt-get install -y python-software-properties
apt-get install -y zip unzip
apt-get install -y curl
# installig mysql
# pre-loading a default password --> yourpassword
debconf-set-selections <<< "mysql-server mysql-server/root_password password yourpassword"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password yourpassword"
echo -e "${COLOR}---installing MySql---${COLOR_RST}"
apt-get install -y mysql-server mysql-client
# installing apache2
echo -e "${COLOR}---installing Apache---${COLOR_RST}"
apt-get install -y apache2
echo -e "${COLOR}---adding php 5.4 ppa---${COLOR_RST}"
add-apt-repository -y ppa:ondrej/php5-oldstable
echo -e "${COLOR}---update again---${COLOR_RST}"
apt-get update
# installing php 5.4
echo -e "${COLOR}---installing php 5.4---${COLOR_RST}"
apt-get install -y php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-mysql
#--------------------------------
#installing laravel
echo -e "${COLOR}---installing laravel in /vagrant/---${COLOR_RST}"
cd /vagrant
#getting laravel
wget -O laravel.zip https://github.com/laravel/laravel/archive/master.zip
unzip laravel.zip
#rename laravel-master to laravel
mv laravel-master laravel
#remove master.zip
rm laravel.zip
cd laravel
#getting composer
echo -e "${COLOR}---getting composer.phar---${COLOR_RST}"
curl -sS https://getcomposer.org/installer | php
#updating laravel
echo -e "${COLOR}---updating laravel---${COLOR_RST}"
php composer.phar update
echo -e "${COLOR}---laravel installation complete---${COLOR_RST}"
echo -e "${COLOR}run: sudo chmod -R 777 ~/MyVagrant/laravel/app/storage${COLOR_RST}"
echo -e "${COLOR}from host to fix permissions on storage directory!${COLOR_RST}"
# run this command from host OS to fix permissions on storage directory
# sudo chmod -R 777 ~/MyVagrant/laravel/app/storage
#--------------------------------
cd ~
# setting document root to laravel/public
echo -e "${COLOR}---setting document root to laravel/public/${COLOR_RST}"
sed -i 's#/var/www/\?#/vagrant/laravel/public/#g' /etc/apache2/sites-available/default
a2dissite default && a2ensite default
# enable mod rewrite for apache2
echo -e "${COLOR}---enabling rewrite module---${COLOR_RST}"
if [ ! -f /etc/apache2/mods-enabled/rewrite.load ] ; then
a2enmod rewrite
fi
# restart apache2
echo -e "${COLOR}---restarting apache2---${COLOR_RST}"
service apache2 restart
# done :)
# test your installation by visiting 192.168.33.10 from your host, you will see Laravel logo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment