Skip to content

Instantly share code, notes, and snippets.

@norbert-codes
Last active June 23, 2016 18:23
Show Gist options
  • Select an option

  • Save norbert-codes/09f15e1f2beda9709b9e to your computer and use it in GitHub Desktop.

Select an option

Save norbert-codes/09f15e1f2beda9709b9e to your computer and use it in GitHub Desktop.
A dead simple LAMP stack box for local development based on scotchbox (https://box.scotch.io/)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
# Naming the VM, to look prettier in e.g. Vagrant Manager VM list (modify to your taste)
config.vm.define "localbox" do |localbox|
end
# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
# - Set the document root to '/' instead of the '/public/' which is default by scotchbox
config.vm.provision "shell", inline: <<-SHELL
mv /var/www/public /var/www/public_html
sudo sed -i s,/var/www/public,/var/www,g /etc/apache2/sites-available/000-default.conf
sudo sed -i s,/var/www/public,/var/www,g /etc/apache2/sites-available/scotchbox.local.conf
sudo service apache2 restart
SHELL
# Creating a trigger config to run right after the box started and do the following:
# - Open the URL for the box in the default browser (need to edit hosts file accordingly)
# NOTE: You will need to install the vagrant triggers plugin: $ vagrant plugin install vagrant-triggers
config.trigger.after :up do
system("open", "http://localbox.local")
end
end
# Making box accessible from local network
# Specify adapter to bridge
Vagrant.configure("2") do |config|
config.vm.network "public_network", bridge: "en0: Ethernet"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment