Get Ruby

sudo apt-get install ruby-full build-essential

Note that ruby-full will install emacs and a slew of other non-essential packages. You can install all the necessary packages with this command:

sudo aptitude install ruby build-essential libopenssl-ruby ruby1.8-dev

Server Installation

If you want to have RubyOnRails running on apache make sure you have installed these first.

sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev

Install the MySQL database and it’s connector

sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql

Installing RubyGems

You can get the latest version of  rubygems from here http://rubyforge.org/frs/?group_id=126

RubyGems via apt

sudo apt-get install rubygems

To make gem work properly you should write gem’s path to PATH add to ~/.bashrc:
export PATH=/var/lib/gems/1.8/bin:$PATH

To export path once just enter previous code to bash.

RubyGems 1.3.5 Ubuntu 9.04

sudo apt-get install rubygems1.8

sudo gem install rubygems-update

Check All are installed:

ruby  -v

ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

gem  -v

1.3.5

rails  -v

Rails 2.3.4

sudo /etc/init.d/apache2 start

After give the above command give this in your browser http://localhost    it shows the apache home page or It works!