Setup Ruby On Rails on Ubuntu 16.04 Xenial Xerus
All commands should be run in Linux terminal (hotkey: Ctrl + Alt + T)
You need to install Ruby on your local machine in development environment. The first step is to install some dependencies for Ruby.
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
You can install Ruby using one of three methods. Some of these conflict with each other, so choose the one that sounds the most interesting to you.
First method: installing with rbenv
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.3.3
rbenv global 2.3.3
ruby -v
The last step is to install Bundler:
gem install bundler
Second method: Installation with rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.3.3
rvm use 2.3.3 --default
ruby -v
The last step is to install Bundler:
gem install bundler
The third method: Installing from source
cd
wget http://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gz
tar -xzvf ruby-2.3.3.tar.gz
cd ruby-2.3.3/
./configure
make
sudo make install
ruby -v
The last step is to install Bundler:
gem install bundler
Rails ships with many dependencies these days, we're going to need to install a JavaScript run time like NodeJS. This lets you use Coffee script and the Asset Pipeline in Rails which combines and minifies your JavaScript to provide a faster production environment.
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Now Install Rails 4.2.6
gem install rails -v 4.2.6 (you may set a specific version of rails)
If you are using rbenv
run the following command:
rbenv rehash
Then run rails -v
to make sure you have everything installed correctly. It should get you your rails version. # Rails 4.2.6