Once we are up to date with the latest available packages, the next step is to install Ruby Version Manager. It is application that allows to manage several different ruby versions easily, we can install RVM and then load it with:
# curl -L get.rvm.io | bash -s stable
# source /usr/local/rvm/scripts/rvm
We must make sure that we have all dependencies from RVM. To make sure that we have all required dependencies, we execute the following command:
It will make sure that we are up to date and install the missing requirements (if any). Once we have RVM installed and configured, we can proceed to install and configure Ruby.
# rvm install 1.9.3
# rvm use 1.9.3 --default
These two commands will install Ruby and set the system to use version 1.9.3 by default. The next step is to make sure we have all components for Ruby on Rails. Ruby Gems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries, a tool designed to easily manage the installation of gems, and a server for distributing them, we can install it with this command and then use it to install Rails:
# rvm rubygems current
# gem install rails
This process could take some time, but after it finish, Ruby on Rails is installed. Next, we need to make sure that we can easily deploy Ruby on rails to any web server. We will install and use Passenger for that. It will serve as interface or bridge for communication between Ruby and the web server, you can install it with the following command:
Once passenger is installed, the rest of the required setup is fully automated. We execute the command:
# rvmsudo passenger-install-nginx-module
Once we do this, it checks for all dependencies automatically and install those that are missing. If some manual user action is required, Passenger will tell us, as well as give us detailed instructions how to do it.
Now we need to configure nginx to “talk” to Passenger. In order to do that, we need to open the nginx configuration file (/opt/nginx/conf/nginx.conf), using our favorite editor and add the following:
In order to create our rails app, we need to install Node.js first
# sudo apt-get install nodejs
Once that is that, we should go to our directory (in this case it is /var/www/rails_app/public) and create the application. After all this is installed and configured, we simply need to start Nginx.
# rails new my_first_rails_app
# sudo service nginx start
We can try and access our new Ruby on Rails application using our browser.