ADS

Sunday, 3 July 2011

How to install Ruby on Rails in ubuntu

Tags: Install, Ruby on Rails, Ubuntu, Howto, How to.

‘Ruby on Rails’  (ROR) is one of the most popular and productive open source framework that allows you to develop web applications very quickly with a lot of fun.



Ruby is a scripting language (like PHP) that focuses on ease of development and beautiful code. Ruby on Rails or simply ‘Rails’ is a web Apps development framework for Ruby programming language.

Rails is a cross-platform – web Apps development framework and this post will guide you in installing ‘Ruby on Rails’ framework on Ubuntu 11.04 (Natty Narwhal) or 10.10 (Maverick Meerkat) or 10.04 (Lucid Lynx) LTS..procedure is same for all versions. gedit text editor is enough for ruby programming – (usually better than heavy weight IDE’s), you can also customize gedit to look like TextMate (very popular (text editor) among ruby developers who uses Mac OS X).

Ruby version 1.8.7 is installed by default, in most of the Linux based operating system or distributions such as Ubuntu, so what you need to install is – ‘Rails’ , Gems (Gems are modular components or libraries very similar to Package in java), git (git is one of the best – free and open source version control system (developed by Linus Torwalds), it is not strictly necessary but recommended) and curl. Before you move on for installing ROR, Apache (Not necessary because ROR ships with WEBrick, the default HTTP server for rails apps) and MySQL or SQLite should be installed.

Installing Ruby on Rails in Ubuntu

#1 : Install git (not necessary but recommended), the version control system.
sudo apt-get install git
or install from source – Download git (Latest Version : 1.7.5.4). Then extract the archive and move to the extracted directory and type the following command(s) to install it -
make && sudo make install

#2 : Install Curl (Command Tool for transferring data with URL Syntax).
Download it (Latest version : 7.21.7) and install in the similar way as you installed git (in step 1, using source)

#3 : Install  Ruby Version Manager (RVM), a command line tool which allows you to run multiple versions of ruby – such as 1.8.7 as well as 1.9.2. Gem will be installed along with this, if not, then install rubygems before proceeding to next step.
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Then type the command given below, to check whether it has been correctly installed, the output after executing the command will be – ‘rvm is a function’
type rvm | head -1

#4 : Install Ruby 1.9.2 (1.8.7 is installed by default)
rvm install 1.9.2
rvm use 1.9.2

#5 : Install Rails
gem install rails

#6 : Install SQLite3 (Not necessary if you want to use MySQL but ROR uses SQLite database by default, so you need to install ruby and sqlite related packages and ORM libraries).
gem install sqlite3
That’s All..now you are ready to rock with ‘Ruby on Rails’. Create new Application using simple command and start the server.
rails new apps_name
cd apps_name
rails server

Now open your browser and type the following address in the address bar -
http://localhost:3000


No comments:

Post a Comment