How to Install Ruby on Rails on Ubuntu 9.04 (Jaunty Jackalope)

Few of my friends have started to learn Ruby on Rails recently. According to my point of view, Windows is not a suitable and enjoyable environment for RoR development. So, I recommended them to start with Ubuntu. Most of them have installed Ubuntu 8.10 and 9.04. So, I wish to write a small guide to setup the Ruby on Rails environment on Ubuntu 8.10 and 9.04
If you like to watch the screencast of this title, rather than reading whole post, you can find my screencast here.
http://mohamedaslam.com/screencast-how-to-install-ruby-on-rails-on-ubuntu/
Ruby installation
First we need to update the repositories.
It’s always a best practice to upgrade the system.
This installation will take few minutes and also require approximately 100 MB disk space.
Now that we are up to date. Let’s start install the RoR recipices. We need following Rails prerequisites.
ruby = An interpreter of object-oriented scripting language Ruby
ri = Ruby Interactive reference
rdoc = Generate documentation from ruby source files
irb = Interactive Ruby
Ruby Gem installation
Next we need to install the Ruby gem package manager. You can download the latest Ruby gems by following link.
http://rubyforge.org/projects/rubygems/
Download and extract the files. (By the time I’m writing this tutorial the latest version is 1.3.1)
cd rubygems-1.3.1
sudo ruby setup.rb
Once it’s done you can delete the .tgz file and rubygems directory.
rm -r rubygems-1.3.1 rubygems-1.3.1.tgz
Next we need to create a set of simlinks. Otherwise it will be a tedious task to type commands with the version (1.8). For an example if we need to call the gem command we’ve to type gem1.8. I don’t prefer that. Hope you too. So, let’s create the necessary simlinks.
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
Rails Installation
Now we can install Rails using gem.
Server Installation
Rails by default comes with the WEBrick server. But most Rails developers prefer the Mongrel server. If you satisfied with WEBrick you can skip this step, else type the following command to install Mongrel server.
If you got any error while installing the Mongrel server, install the ruby-dev / ruby1.8-dev and try again.
Database Installation
Rails 2.3 shipped with SQLite3 as it’s default database instead of MySQL. You can install SQLite3 libraries by following commands.
sudo gem install sqlite3-ruby
If you prefer MySQL,
sudo gem install mysql
Create Ruby on Rails App
Now that we have completed everything successfully. You can create your new Ruby on Rail applicaion by following command.
If you need MySQL supported applicaion you need to specify as follows
Run the app
script/server
navigate you browser to http://localhost:3000
Wola.. you have done it…!
Happy Rails…!
Related Articles
Tags: Framework, Ruby on Rails, Ubuntu 8.10, Ubuntu 9.04, Web Development
This entry was posted on Tuesday, April 28th, 2009 at 6:52 am and is filed under How to, Ruby on Rails, Ubuntu, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.


