Skip to content

Instantly share code, notes, and snippets.

@michaelenger
Last active August 29, 2015 13:59
Show Gist options
  • Save michaelenger/10732735 to your computer and use it in GitHub Desktop.
Save michaelenger/10732735 to your computer and use it in GitHub Desktop.
Witi Vagrant example
#!/usr/bin/env bash
# This is a general shell script you can use for whatever you want. Just note that you don't need to
# "sudo" anything as you're already running with the correct permissions.
# General Stuff
apt-get update
apt-get install -y curl vim
# Apache
# Install Apache2, which will install it as a service that starts automatically. Then we remove the
# default folder and symlink to the witi one which is synced from outside the VM.
apt-get install -y apache
rm -rf /var/www
ln -sfn /home/vagrant/witi/ /var/www
# Enable the override in the default site by regex-replacing any "AllowOverride XXX" in the config file to
# a temporary file and then replacing it (you can't replace it directly with sed apparently)
src=$(mktemp)
sed "s/\(AllowOverride *\)\w*/\1All/" /etc/apache2/sites-available/default > $src
mv $src /etc/apache2/sites-available/default
# Enable the mod and restart the server
a2enmod rewrite
service apache2 restart
# PHP
# Install PHP and the Apache2 module as well as the GD module which you use to create thumbnails.
apt-get install -y php5 php5-gd libapache2-mod-php5
# MySQL
# This line will prompt you for a password and so I just run it manually (using sudo).
#sudo apt-get install -y mysql-server mysql-client php5-mysql
# -*- 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|
# The box (VM image) to use. vagrantcloud.com has a list of possible ones, but I'm a Debian/Ubuntu guy.
config.vm.box = "nfq/wheezy"
# This is used to forward ports to this VM, meaning if you go to http://localhost:8080 then it'll be
# forwarded to the VM on port 80 (the web server port). I tend to not use this, but use the private
# network instead.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Using this setting, I am able to connect to the VM using http://192.168.33.10 (if it's running a
# web server, of course).
config.vm.network "private_network", ip: "192.168.33.10"
# This is the folder which I want to sync up, meaning the "./witi" directory on my host machine is
# accessible in the VM at "/home/vagrant/witi". You should obviously point this to wherever you have
# your local witi installation.
# You can add as many synced folders as you want, btw :D
config.vm.synced_folder "./witi", "/home/vagrant/witi"
# This is my provisioning file, which is just a shell script. It will be run when you create the VM for
# the first time, but also any time you run "vagrant provision" or "vagrant up --provision". It's meant
# to setup your VM with the stuff you like.
config.vm.provision :shell, :path => "bootstrap.sh"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment