Installing Ruby on Rails on Ubuntu 10.04

This is the first tutorial post on Apsotech blog. There are several tutorials available on Internet which guides through Ruby and Rails installation. This post is very particular about installing ruby version  1.9.3p194  and rails version 3.2.13. Lets get started.
Follow the below steps carefully if you get any error in between please solve the issue before going to the next step.

Installing ruby

Download the source file here.
Copy the file to home folder and open terminal, type the command

prathviraj@apsotech:~$tar xvjf ruby-1.9.3-p194.tar.gz 

prathviraj@apsotech:~$cd ruby-1.9.3-p194/

Install dependency
prathviraj@apsotech:~/ruby-1.9.3-p194$sudo apt-get install libyaml-dev

Compile, make and install

prathviraj@apsotech:~/ruby-1.9.3-p194$sudo ./configure
prathviraj@apsotech:~/ruby-1.9.3-p194$sudo make
prathviraj@apsotech:~/ruby-1.9.3-p194$sudo make install 

Now you have installed ruby on your machine. To confirm, check the ruby version

prathviraj@apsotech:~/ruby-1.9.3-p194$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]

Rails Installation
Now time to install rails using gem. I am not using apt-get repository for rails as it does not provide all the packages needed and its not up to date, instead I am using gem repository which is directly backed by ruby repository.

Install curl
prathviraj@apsotech:~$sudo apt-get install curl

Now download gem
prathviraj@apsotech:~/ruby-1.9.3-p194$sudo curl -L | bash -s stable --ruby -V

To install rails just type
prathviraj@apsotech:~/ruby-1.9.3-p194$sudo gem install rails 
It may take some time depending on your Internet speed.
After completion check your rails version 
prathviraj@apsotech:~/ruby-1.9.3-p194$ rails -v
Rails 3.2.13

Now create a project. I would suggest you to do it inside home directory
prathviraj@apsotech:~$ rails new projectname -d mysql 
prathviraj@apsotech:~$ cd projectname/

Now download all necessary gem files here 
Extract the file and place it inside directory ~/projectname/vendor/

Before going ahead, you need to install some dependecies for mysql2 gem. Type
prathviraj@apsotech:~/projectname$ sudo apt-get install mysql-client libmysqlclient-dev

Install all the gem files
prathviraj@apsotech:~/projectname$ bundle install --local 

Congratulations!! If you are lucky enough to go through all the installation steps. 

16 comments: Leave Your Comments

  1. Error instaling gem file
    $sudo gem install rails

    It seems your ruby installation is missing psych (for YAML output).
    To eliminate this warning, please install libyaml and reinstall your ruby.

  2. after doing this-- sudo gem install rails
    it ask for password nd then it stops(not downloading anything)

  3. First install this
    sudo apt-get install libyaml-dev

    Then rebuild Ruby

  4. Thank you :) Worked on my PC

  5. error macha

    sudo gem install rails -V
    ERROR: Loading command: install (LoadError)
    cannot load such file -- zlib
    ERROR: While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

  6. Second step says :$cd ruby-1.9.3-p194/
    but in third step ur still in ur home directory..
    do v have to do rest of installation in our home directory..???

  7. i m unable to install gem rubyracer

    Building native extensions. This could take a while...
    ERROR: Error installing therubyracer:
    ERROR: Failed to build gem native extension.

  8. Great Article.
    This is nice information blog , The first thing I noticed about your blog is how well designed and unique looking it is. I wish you the best.

    Ecommerce Website Design Mumbai

  9. Rails development is a web-application framework that includes the whole thing needed to generate database-backed web applications according to the Model-View-Controller (MVC) pattern. Understanding the MVC prototype is key to accepting Rails. MVC divides your application into three layers, each with a precise accountability. Installing ROR on Ubuntu is not of fresher task, you need to be well known with Ubuntu too.

  10. Not so far I have found new cool tool to work with mySQL on ubuntu – Valentina Studio. Its free edition can do things more than many commercial tools!!
    I very recommend check it.

  11. All the information of this blog is very useful because it have all the installation of application with detailed description.
    Web Design Company | Web Development Company

  12. I am just about satisfied together with your sensible perform. You position incredibly really useful details. Keep it up. Keep composing a weblog. Trying to research your next post.
    web designing companies bangalore | website design company in bangalore

  13. Nice share! Interesting read and looking forward in learning more.

  14. very nice information sharing...

  15. very useful information sharing...