Install Ruby On Rails 4.0.2 and RVM on Raspbian – raspberry pi


Ruby Rails is a Web application framework created in 2004 intended as a rapid development web framework that runs the Ruby programing language. The latest version of the Ruby is ‘Ruby 2.1.0‘ and was released in December 2013, it brings many new features and bug fixes. Raspberry Pi is is a credit-card-sized computer designed with the intention of promoting the teaching of basic science and programing. Therefore it a great cheap machine to setup your own Ruby on Rails server to help you start learning this great system.

This tutorial will guide you through the installation of the latest version of ruby and rail on a Rasbery Pi, I’m using the latest version of raspbian. I will also only be using the command line so there is no need to start you desktop environment.

First of all you’ll need to install some packages that Ruby, RVM and RubyOnRails will require later, the easiest way to do this is using the repositories so go ahead and type:

sudo apt-get update
sudo apt-get install -y git curl zlib1g-dev subversion

Now let’s install the latest version of RVM using curl:

\curl -sSL https://get.rvm.io | bash -s stable

Saddly you shell does not know about RVM, this is normaly resolved by restating your raspbery pi, alternativly simply run the following command:

\curl -sSL https://get.rvm.io | bash -s stable

Now you’ll need to ask RVM if it needs any more programs and if so you’ll need to install them to do this type:

rvm requirements

This little beaut will automatically install any required packages (you may be required to enter your login password during this stage), this will also take some time.

Once you have installed all these packages its time to install Ruby 2.1.0 herself. The following command will install Ruby 2.1.0.using the rvm package onto your raspbery pi. However this will take a few minutes (1 hour 30 in my case) rember your raspbery PI is only the size of a credit card, I recommend getting a drink, or my favourite, a pizza and play minecraft 😆 .

rvm install 2.1.0

This should look something similar to this:

Capture

You can test that Ruby is installed correctly and running at version 1.9.2 by typing

ruby -v

This should output something like the following screenshot, showing you that version 2.1.0 is installed and is now the default Ruby version.

Capture1


The nice thing about RVM is you can use it to install any version of Ruby and switch between the versions your have installed, to do this just enter "rvm install [Version Number]" then "rvm --default use [Version Number", you can then use "rvm --default use" to change to any installed version. Now that you have the latest version of ruby installed I’m sure you want to get the latest version of Rails installed, at the time of writing this tutorial that’s Rails 4.0.2. To install Rails we can use GEM which is installed along with RVM and Ruby, to install the latest version of Rails just type, (this also takes a while about 2 hours):
gem install rails
Now after your long waits (any many pizzas) you'll have installed RVM, Ruby 2.1.0 and Rails 4.0.2 on your Raspberry PI, this will be configured to use sqlite3 as default, you can now setup your new Rails application with
rails new [project name]
TODO: how to start the server Just as a final note, If you want to use MySQL instead of sqlite3 you'll need to enter the following
sudo apt-get install mysql-server
gem install mysql2
rails new [project name] -d mysql

Comments are closed.