Using VirtualBox and Vagrant
Install virtualbox and Vagrant:
$ brew cask install virtualbox
$ brew cask install vagrant
Add ubuntu 12.4
$ vagrant box add precise64 http://files.vagrantup.com/precise64.box
Setup the vagrant box for your project:
$ cd myproject
$ vagrant init precise64
All the configuration is done by editing the Vagrant
file.
First add a shared folder to see the current folder from the virtual machine:
config.vm.synced_folder ".", "/home/vagrant/my-project"
Then add forwarded ports to connect to the web server of the VM from outside:
config.vm.network "forwarded_port", guest: 3000, host: 3333
Start and connect to the virtual machine:
$ vagrant up
$ vagrant ssh
If you want make changes to Vagrant file you need to reload:
$ vagrant reload
All the following steps are required to be executed inside the vm unless notice
Install the required software:
$ sudo apt-get update
$ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
Install rbenv:
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ cd ~/.rbenv && src/configure && make -C src
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Install ruby-build:
$ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
Reload bashrc:
$ source ~/.bashrc
Install ruby:
$ rbenv install 1.8.7-p374
Install mysql:
$ sudo apt-get install mysql-server mysql-client libmysqlclient-dev
$ gem install mysql2
Install bunlder:
$ gem install bundler
$ rbenv rehash
and install dependencies:
$ bundle
With an old ruby (~1.8) I needed to add an older version of rdoc to the Gemfile:
gem 'rdoc', '4.2.0'
And then the classic stuff:
rake db:create db:migrate
script/server
Hopefully you can connect to http://localhost:3333 and see the app running. Congrats!