Installing Ruby On Rails in Ubuntu 11.04

I just installed Ubuntu 11.04 Natty.

I wanted to install Ruby 1.9.2 and  rails 3.0.9

So I followed the steps below.

I hope this helps you.

  • We need to install all required packages.
$ sudo apt-get install gcc g++ build-essential libssl-dev 
libreadline5-dev zlib1g-dev linux-headers-generic libsqlite3-dev
  • Now download Ruby 1.9.2 sources, unpack them and install:
$ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz 
$ tar -xvzf ruby-1.9.2-p0.tar.gz $ cd ruby-1.9.2-p0/ 
$ ./configure --prefix=/usr/local/ruby
$ make && sudo make install
  • Add path to binary Ruby files(this is quite important as without this step, if you type ruby -v on terminal..it wont show up.)
$ sudo gedit /etc/environment
  • You need to add in the PATH variable that path – /usr/local/ruby/bin, should look something like this:

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ruby/bin”

  • Then run the source command for the file /etc/environment to apply changes.
$ source /etc/environment
  • Now check is Ruby installed properly:
$ ruby -v
  • You should see something like this: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
  • Now create a symbolic link for ruby and gem program
$ sudo ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby 
$ sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem

  • Now its time to download and install rubygems.
  • You can download rubygems from here.
  • After downloading, it unpack it.
  • From the terminal, traverse to the unpacked directory and type the following:

$ ruby setup.rb

  • Now install the required gem packages, including Rails 3.:
 $ sudo gem install tzinfo builder memcache-client rack rack-test 
 erubis mail text-format bundler thor i18n sqlite3-ruby
 $ sudo gem install rack-mount --version=0.4.0
 $ sudo gem install rails --version 3.0.9

  • Note that if you dont give the version…latest version will be installed
  • Check Rails version:

rails -v

Thats it.

Now create magic with magic of rails.

Hope this helps.


			

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s