In the Ubuntu Hardy setup article Ubuntu Hardy - Setup we secured, updated and personalised the install ready to add some working software.
We also installed the build-essential package. Now we can go ahead and install Ruby on Rails.
This articles has been updated to use the latest (at the time of writing) version of rubygems which is v1.2.0.
This version of rubygems has finally fixed the memory issues seen on smaller Cloud Servers.
You can now install, update and administer all your rubygems from within a 256 Cloud Servers with no issues.
The process will involve a mix of installation methods - the main ruby packages and dependencies will be installed using the 'aptitude' package manager but rubygems will be install from source.
The reason for this is that it is important to get the latest and most stable version of rubygems onto the Cloud Server and the easiest way to do that is by installing from source.
Let's go ahead and install ruby. Note the install command shown below includes the sqlite3 db package.
Rails version 2.0+ uses sqlite3 as its default database - you can, of course, use other databases and indeed, there will be articles specifically aimed at other databases.
However, for now, we'll stick to the basics and get the main Ruby on Rails packages installed:
sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8
We need to create some symlinks from the install to locations every programme would look:
sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby sudo ln -s /usr/bin/ri1.8 /usr/bin/ri sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc sudo ln -s /usr/bin/irb1.8 /usr/bin/irb
Once done, we can have a look at the Ruby version:
ruby -v ... ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
Good, now we can move onto installing rubygems for our Rails installation.
As mentioned, we're going to install rubygems from source.
Let's go ahead and download the source code into our sources directory. If you haven't got a sources directory, you can simply create one:
mkdir ~/sources cd ~/sources
At the time of writing the latest rubygems version is v1.2.0.
As mentioned above, this release fixes the memory issues found with earlier versions of rubygems.
As normal, please check for the latest release on the rubygems homepage.
Let's download v1.2.0:
Now unpack it and move into the newly created folder:
tar xzvf rubygems-1.2.0.tgz cd rubygems-1.2.0
Now we can go through the simple process of compiling it and creating a symlink:
sudo ruby setup.rb ... sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
Once done, we can check the gem version with a:
gem -v ... 1.2.0
We need to do a quick update to rubygems:
sudo gem update
Although nothing will change as we have installed the latest version, a '--system' update will ensure everything is the latest and greatest:
sudo gem update --system
Continuing with the Rails installation, we can go ahead and install it:
sudo gem install rails
Once completed, you can check what gems were installed with a:
sudo gem list
Which gives the following (from a fresh Cloud Server and no other gems installed):
*** LOCAL GEMS *** actionmailer (2.1.0) actionpack (2.1.0) activerecord (2.1.0) activeresource (2.1.0) activesupport (2.1.0) rails (2.1.0) rake (0.8.1)
Now we can do a simple test to see if the sqlite3 module is working:
irb #irb(main):001:0> require 'sqlite3' => true #irb(main):002:0> exit
If the result does not return 'true' the you may have missed a step.
Finally, we need to install postfix and subversion so we can 'check-out' plugins and send mail from our Rails applications:
sudo aptitude install postfix subversion -y
Answer the postfix questions as you see fit but the defaults usually suffice for our purposes as we are only using it to send emails and not for receiving mail.
You now have a Ruby on Rails and postfix/subversion stack setup and ready to roll.
Now you are ready to install the server of your choice whether that be Litespeed, Nginx or Apache.
© 2011-2013 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License