Let’s install Ruby 1.9.2 and Rails 3 stable on Ubuntu. I’m going to use just one Ruby version so, this installation without RVM (Ruby Version Manager). I’m using Ubuntu 10.04, 32 bit version.
If you have not yet installed the following packages - install them:
$ 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.
$ 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
Ruby 1.9.2 is already includes Rubygems, so you do not have to install it.
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.0
Check Rails version:
$ rails -v
You should see the version number 3.0.0. Otherwise, try to execute command source /etc/environment and enter rails -v command once again.
Now you are ready to create a new Rails 3 application:
$ rails new myproject
cd myproject
rails server
UP: To update rails to latest version (3.0.3 for now), run:
sudo gem update rails
And change rails gem in your Gemfile to gem ‘rails’, ‘3.0.3′