Skip to content

Instantly share code, notes, and snippets.

@electricg
Last active August 29, 2015 14:05
Show Gist options
  • Save electricg/11fb42e45684bbeddd6f to your computer and use it in GitHub Desktop.
Save electricg/11fb42e45684bbeddd6f to your computer and use it in GitHub Desktop.
Ubuntu vagrant example

In the host machine, update the hosts file with 127.0.0.1 giulia.nix.

After installing Vagrant, run vagrant box add hashicorp/precise32.

Clone the project and move inside the directory.

vagrant up to start the machine.

vagrant halt to shut down the machine.

vagrant ssh to connect to the machine.

vagrant reload required for changes made in the Vagrantfile to take effect.

vagrant destroy to erase the machine.

#!/usr/bin/env bash
sudo apt-get update
# Install apache and ssl
sudo apt-get install -y apache2
sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 restart
# Install php5
sudo apt-get install -y libapache2-mod-php5
sudo a2enmod php5
# Install mysql with PHP 5
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root_password'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root_password'
sudo apt-get install -y mysql-server libapache2-mod-auth-mysql php5-mysql
# Install php curl
sudo apt-get install -y php5-curl
# add url to hosts file
sudo sed -i '$ a\127.0.0.1 giulia.nix' /etc/hosts
# Intall node
# https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
sudo apt-get install -y software-properties-common python-software-properties
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -y python g++ make nodejs
# Install git
sudo apt-get install -y git
# Install curl
sudo apt-get install -y curl
# Install nodemon
sudo npm install -g nodemon
# Install grunt
sudo npm install -g grunt-cli
# Installing Ruby 1.9.3 on Ubuntu 12.04 Precise Pengolin (without RVM)
# http://leonard.io/blog/2012/05/installing-ruby-1-9-3-on-ubuntu-12-04-precise-pengolin/
sudo apt-get update
sudo apt-get install -y ruby1.9.1 ruby1.9.1-dev \
rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \
build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1
# choose your interpreter
# changes symlinks for /usr/bin/ruby , /usr/bin/gem
# /usr/bin/irb, /usr/bin/ri and man (1) ruby
sudo update-alternatives --config ruby
sudo update-alternatives --config gem
# now try
ruby --version
# -*- 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 = "hashicorp/precise32"
# config.vm.network "forwarded_port", guest: 80, host: 3333
config.vm.network "private_network", ip: "192.168.66.66"
config.vm.synced_folder "/Users/giulia/Sites", "/var/www/"
# https://github.com/mitchellh/vagrant/issues/1673#issuecomment-28288042
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# 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