Rails 3/Installing Ruby and Rails
In this section we will be seeing how to install Ruby on Rials on Ubuntu GNU Linux distro. At the point of writing this piece of text we have Ubuntu 10.10. We will see how to install Rails 3.x.x in it.
The first step is to launchyour terminal by going to Applications -> Acessories -> Terminal.
First we will be installing tools that will compile Ruby source code to do so in your terminal type the following
$ sudo apt-get install gcc g++ build-essential libssl-dev libreadline5-dev zlib1g-dev linux-headers-generic libsqlite3-dev
Next we will download Ruby source code using wget. To do so type the following in terminal
$ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
The above command will download Ruby 1.9.2 source code. The downloded file is in tar.gz format, it must be unzipped, to do so type the following
$ tar -xvzf ruby-1.9.2-p0.tar.gz
Next we will compile and install Ruby using the following commands (Type the commands one by one):
$ cd ruby-1.9.2-p0/ $ ./configure --prefix=/usr/local/ruby $ make && sudo make install
Next we need to tell our operating system that Ruby is installed in /usr/bun/ruby, to do so we need to add the path to /etc/enviornments file. To do so, type the following
$ sudo gedit /etc/environment
The file opens and you must be able to see something like this
To the path string add :/usr/local/ruby/bin , it must at last look something like this
Then run the source command for the file /etc/environment to apply changes.
$ source /etc/environment
Now check if everything is OK by typing
$ ruby -v
The output must be somewhat like this:
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
Now we will create symbolic link to ruby and gem using the following commands
$ sudo ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby $ sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem
Now we will install rails with gem using the following commands (type them one by one in terminal):
$ 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
To check type rails -v, you must get output like something shown below:
$ rails -v Rails 3.0.3
When I installed Rails 3.0.3 was the stable version of Rails hence it got installed. Having installed our Rails web framework successfully lets create our first web application.