Steps for setting up Laravel via Vagrant.
#!/usr/bin/env bash
# Update
apt-get update -y -qq > /dev/null
# Install core linux utilities
apt-get -y -q install build-essential
apt-get -y -q install git-core tmux vim curl
# Install apache and php
echo 'vagrant: installing apache and php.'
apt-get -y install apache2 php5 php5-mysql
# Updating /var/www
echo 'vagrant: updating /var/www.'
rm -rf /var/www
ln -fs /vagrant /var/www
# Add servername to httpd.conf and setup virtualhosts file
echo 'vagrant: updating servername.'
echo "ServerName localhost" > /etc/apache2/httpd.conf
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "/vagrant"
ServerName localhost
<Directory "/vagrant">
AllowOverride All
</Directory>
</VirtualHost>
EOF
)
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default
# Enable mod_rewrite
echo 'vagrant: enabling mod_rewrite for permalinks.'
a2enmod rewrite
# Restart Apache
echo 'vagrant: restarting apache.'
service apache2 restart
# Set a temp password of 'vagrant' for root mysql user
# This can be changed post installation
# Note: MySQL setup will be non-interactive
echo 'vagrant: setting root privileges pre mysql-server install.'
debconf-set-selections <<< 'mysql-server mysql-server/root_password password vagrant'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password vagrant'
# Install mysql-server
apt-get -y -q install mysql-server
# PHP by default is 5.3.10, follow this guide to go to 5.4:
# http://www.barryodonovan.com/index.php/2012/05/22/ubuntu-12-04-precise-pangolin-and-php-5-4-again
# Install php modules
echo 'vagrant: installing php modules.'
apt-get -y install php5-cli php5-curl php5-mcrypt
# Install Composer and make available globally
echo 'vagrant: installing composer.'
curl -sS https://getcomposer.org/installer | php
echo 'vagrant: making composer available globally.'
mv composer.phar /usr/local/bin/composer
# Install Laravel
echo 'vagrant: installing laravel via curl.'
curl -O http://laravel.com/laravel.phar
echo 'vagrant: renaming and moving laravel.'
mv laravel.phar laravel
mv laravel /usr/local/bin
# Change permissions
echo 'vagrant: changing permission on laravel executable to 755.'
chmod 755 /usr/local/bin/laravel
echo 'vagrant: vagrant is finished.'
# "app_name"/storage also needs permissions but as it is tied to the host computer,
# and it has to be changed for each project, it is better to set them there.
# Here is an example
#
# chmod -R blog/app/storage
# Database config: app/config/database.php
# You must manually create your database in mysql and enter it under the config
# for your chosen database software, along with the other details specified in this
# file.
#
# You can use mysql at the command line to do this:
# mysql -uroot -p
# CREATE DATABASE blog;
#
# Migrations are carried out using artisan and php files
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise32"
config.vm.network :forwarded_port, host: 5401, guest: 80
config.vm.provision :shell, :path => "bootstrap.sh"
end