Start a Rails Project

Step by Step

Step 1

1
2
3
4
mkdir <project name>
cd <project name>
vagrant init ubuntu/trusty64
vagrant up

Step 2

Change the memory size, which is necessary for developing.
We also give the virtual machine a fixed IP address for convenience.
Modify Vagrantfile with your favourite editor, adding the following lines.

1
2
3
4
config.vm.provider "virtualbox" do |v|
v.memory = 2048
end
config.vm.network :private_network, ip: "192.168.33.33"

and then

1
vagrant reload

More for IP address,

1
sudo vim /etc/hosts

and add

1
192.168.33.33 <project name>.dev

Step 3

Time for installing rails.

1
vagrant ssh

and type in following lines one by one

1
2
3
4
sudo apt-get update
sudo apt-get install -y git-core curl zlib1g-dev build-essential \
libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \
libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common

Install rbenv, which is a tool for installing ruby and version control of ruby.

1
2
3
4
5
6
7
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

Now is ruby

1
2
rbenv install 2.1.2
rbenv global 2.1.2

Next is rails

1
echo "gem: --no-ri --no-rdoc" > ~/.gemrc

This is for simplicity.

1
2
gem install rails -v 4.1.2
rbenv rehash

Now database.

1
sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Environment ready!

Reference