Nov 2, 2007

Quick Ruby on Rails on Ubuntu 7.10 (and 8.04 and 9.04)

There are many howto's on this subject out there, but since I ended up blending a few of them to get exactly the environment I wanted setup (and took notes so I could repeat this), I thought I'd blog it for future reference, and hopefully this info is useful to others.

So, what exactly do I want: a development and deployment machine with the following specifications:
  • A recent Ubuntu Linux, in this case 7.10 (Gutsy Gibbon) [update: I also installed on 8.04, hardy heron beta, with good success]
    [update2: I have now installed on 9.04, with a few changes]
  • Web-App server comprised of apache2, mongrel, ruby on rails, mysql5
  • Development environment comprised of Aptana RadRails (based on eclipse), for both Java and Ruby on Rails development (I use Java for other projects, but also plan to do some JRuby work), and since eclipse rocks, I use it for everything I can, even rails. If you don't want java development, you can use the pure Aptana IDE, but then you also loose out on CVS support).
  • Some additional libraries for graphics and charting support in the rails apps.
The quickest setup procedure that worked for me, on four very different computers, a Dell Precision 380 desktop, an Acer Aspire 3100 laptop and most recently a Packard Bell quad core workstation and Acer Aspire 7530G, was:
  1. Install ubuntu. I simply did a standard install from the live cd (downloaded from
  2. Update all packages. I usually just click the update icon on the top right of the screen, but you can use synaptic ('mark all updates' and then 'apply'), or apt-get with the following commands:
    • sudo apt-get update
    • sudo apt-get upgrade
  3. Install packages required for this setup. I used synaptic, but you could just as easily use 'sudo apt-get install ...':
    • sun-java6-jdk / openjdk-6-jdk (includes a number of other required packages)
    • sun-java6-source / openjdk-6-source (optional)
    • joe (just my preferred old text editor, you choose what you like)
    • flashplugin-nonfree (since I will need that for some sites I view/develop)
    • ruby-full (bundles a bunch of ruby packages, including irb, rdoc and ri, but not rake and rubygems, see later for those - do not install them as ubuntu packages now)
    • apache2 (provides version 2.2)
    • mysql-server (provides version 5.0)
    • libsqlite3-dev (required for the gem install of sqlite3-ruby, if you need that)
    • build-essential (provides a c/c++ development environment required by some ruby gems which build on install)
    • libmysqlclient15-dev (required by the mysql ruby library)
    • eclipse (for 3.2 support in ubuntu 7.10 and 8.04) - to get eclipse 3.3 or 3.4 you need to download it from
    • On recent versions of Ubuntu (like 9.04) you also need to install xulrunner as described at this link. This is to get around a library issue between SWT (in eclipse) and Firefox3.0.
  4. Install rubygems from source. This is a contested point, as ubuntu provides rubygems as a package also, but since it is a package management facility itself, it can conflict with the debian package management provided by ubuntu, so it is easiest to keep it completely separate:
    • wget
    • tar xzvf rubygems-1.3.4.tgz
    • cd rubygems-1.3.4
    • sudo ruby setup.rb
    • sudo ln -s /usr/bin/gem1.8 /usr/bin/gem # This was not required for rubygems 0.9.4, but is required now on ubuntu with rubygems 1.0.1 and above
    • sudo gem update --system # With 0.9.4 I needed to repeat this as the first time gave an error, but with 1.0.1 and 1.3.4 it worked first time
  5. Use rubygems to install rails and some other useful gems using the command 'sudo gem install X' where X is any number of the following (I did all):
    • rails # this includes dependencies like rake
    • mongrel # for the deployment server
    • mongrel_cluster # if you want to try out clustering
    • capistrano # if you want to do the easy deployment as described in the 'agile' book
    • mysql # for mysql database access from ruby
    • termios # well, this was mentioned in several blogs and the agile book, so I just did it :-)
    • sqlite3-ruby (sqlite3 is now the default database in rails2, so you might need this)
  6. Add the Aptana Radrails plugins to the eclipse IDE:
    • Start eclipse from the applications menu
    • Go to menu 'Help->Software Updates->Find and Install'
    • Select 'Search for new features to install' and click 'Next'
    • Click 'New Remote Site'
    • Enter name as 'Apatana' and URL '' and click OK
    • Click 'New Remote Site' again
    • Enter name as 'Apatana Radrails' and URL '' and click OK
    • Click 'finish' to start the search for updates
    • Once the search is complete, you should check both 'aptana' and 'aptana radrails' and click 'next' to install
    • Accept the license agreement and click 'next' and then 'finish' to start the actual download
    • When prompted click 'install all' to finish the install
    • Restart eclipse
  7. Modify Eclipse to use Java6 (based on For Ubuntu 8.04 and 9.04, this was not necessary, but I did it for Ubuntu 7.10 and earlier.
    • edit /etc/eclipse/java_home and move java6 up in the list so that eclipse uses java6 for running itself (which is faster)
    • To get projects inside eclipse to use java6, open eclipse and go to the menu 'Window->Preferences->Java->JREs' and select the Java6 JRE.
  8. Add some extra libraries to rails (optional, depends on your apps):
    • I wanted ImageMagick for photo uploads and resizing in my rails apps, so I installed the ubuntu package for ImageMagick using synaptic, and then installed the rubygem 'mini-magick'. I had tried 'RMagick', but the gem did not install, and online help indicates that you need to re-install ImageMagick from source to get RMagick to work, so I opted for the simpler mini-magick.
    • For charting support in my web apps, the popular approach of using 'gruff' wrapping ImageMagick seemed to generate a lot of help requests, so I went for the lighter approach of using client side flash as described in the following blog.
    • For nicer color control, I installed pdf-writer to get the color-tools gem (and in case I needed pdf-writer itself for future development).
  9. Once you have created a rails app, using the usual 'rails myapp', you should consider adding a number of cool rails plugins. There are a huge number out there. Currently I'm using attachment_fu, will_paginate, acts_as_state_machine, restful_authentication and ext_scaffold. See some of my more recent blogs for some more info on these.
  10. Miscellaneous. I also changed my ubuntu font sizes down to 9pt on 'system->preferences->appearance' to get a bit more screen real-estate on the laptop. Windows uses smaller fonts so it looks better (to me), especially when developing in an IDE like eclipse where it is nice to have many panels open together. And for some reason the Ubuntu install had visual effects disabled (Composite extension not available), so I needed to edit /etc/X11/xorg.conf and change the "0" to a "1" on the Composite line near the end of the file. And I changed the theme to 'glossy' but with 'human' icons and darker colors. Looks cool now!
Well, quiet a few steps, but most of the time the computer is downloading packages, updates, plugins and gems from the internet, so you can just lounge around with a good latte :-)

And of course the required screenshot, this one is of the Acer laptop with firefox showing this page and eclipse with a Ruby on Rails application in production (ubuntu 7.10).

Next steps - there are lots of blogs out there on setting up production deployments for rails, and here's one I just read: