• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

Ubuntu - Ruby on Rails


In the Ubuntu Intrepid setup articles (Ubuntu Intrepid - Setup) we secured, updated and personalised the install ready to add some working software.

Ubuntu Intrepid setup - page 2


Contents

Update

This articles has been updated to use the latest (at the time of writing) version of rubygems which is v1.3.1.

Process

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.

Ruby

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

Symlink

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

Version

Once done, we can have a look at the Ruby version:

 
ruby -v
...
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]

Good, now we can move onto installing rubygems for our Rails installation.

Rubygems

As mentioned, we're going to install rubygems from source.

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.3.1.

As normal, please check for the latest release on the rubygems homepage.

Let's download v1.3.1:

 
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz

Now unpack it and move into the newly created folder:

 
tar xzvf rubygems-1.3.1.tgz
cd  rubygems-1.3.1

Now we can go through the simple process of compiling it and creating a symlink:

 
sudo ruby setup.rb
...

The compile and install process will take a minute or two to run, and when it's finished you should see the following displayed at the bottom of the output text:

 
RubyGems installed the following executables:
    /usr/bin/gem1.8
 
If `gem` was installed by a previous RubyGems installation, you may need
to remove it by hand.

Let's create another symlink:

 
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Version

Once done, we can check the gem version with a:

 
gem -v
...
1.3.1

Good.

Update

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

Rails

Continuing with the Rails installation, we can go ahead and install it:

 
sudo gem install rails

It may take a few minutes to run, and 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.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (2.2.2)
rails (2.2.2)
rake (0.8.3)

Done.

sqlite3 test

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.

Postfix and subversion

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.

That's it

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


See license specifics and DISCLAIMER

4 Comments

Hi,
It might have worked years ago. Oh well.

root@pschon:/home/pschon/sources/rubygems-1.3.1# gem install rails
ERROR: Error installing rails:
i18n requires RubyGems version >= 1.3.5


This does need to be updated (or completely revamped), but for now, I believe recent versions of Ubuntu have a "rubygems" package you can install instead of needing to install Ruby Gems manually. That should ensure it works with the version of Ruby the distro version wants to install.

Got a mmemory map dump which I've not seen before when trying to install ruby 1.8 so I then went back to this but it did not work

Guys, try this out. I needed to move a site for a client that is running rails 2.2.2, this shows me how to install a specific version of ruby gems:

http://po-ru.com/diary/how-to-update-rubygems-to-a-specific-version/

The writer tries to be fancy and puts two lines into one command. Don't do that just do one at a time (doing it his way didn't seem to work at first)

Add new comment