Open your terminal and run
\curl -sSL https://get.rvm.io | bash -s stable
When this is complete, you need to restart your terminal for the rvm to work.
Now, run rvm list known
This shows the list of versions of the ruby.
Now, run rvm install ruby-2.4.1
If you type ruby -v
in the terminal, it still shows you ruby 2.0.
To use the latest installed version. Run rvm use ruby-2.4.1
To set this as the default version, run rvm use ruby-2.4.1 --default
install rails
gem install rails -v 4.2
gem install passenger
passenger-install-apache2-module