Posted by & filed under AWS/Linux/Unix/Devops stuff, Ruby on Rails, Web Development.

The following cut-and-pasteable instructions will bring up a Vagrant VM hosting a Rails project

  • cd into project folder
  • vagrant init
  • vagrant box add precise32 http://files.vagrantup.com/precise32.box   (this can be whatever Ubuntu version you want)
  • edit created Vagrantfile, modify the following to match your created box name: config.vm.box = “precise32″
  • add “config.vm.network :forwarded_port, host: 3000, guest: 3000″ to Vagrantfile within Vagrant.configure() block
  • vagrant up
  • vagrant ssh
  • files in your local project directory where Vagrantfile lives are automatically synced to /vagrant within the VM, you should find them there
  • configure Rails inside VM:
    • sudo su -
    • apt-get -y update
    • aptitude full-upgrade     (to update OS – optional)
    • apt-get install ruby-rvm mysql-client mysql-server libmysqlclient-dev  (set a MySQL root password you can remember)
    • control-D to log out of root and switch back to vagrant user
    • rvm install 1.9.3-p448    (or whatever version of Ruby you want)
    • rvm use 1.9.3-p448 –default
  • log out and vagrant ssh back in to reload environment
  • cd /vagrant
  • bundle install
  • create MySQL user/grants and database needed for app
  • rake db:migrate
  • rake db:seed
  • rails server
  • make sure local firewall doesn’t block port 3000
  • access your project via http://localhost:3000