Mar 19 2009

Howto install rails 2.3 and ruby 1.9 on ubuntu for mysql and sqlite3

Prerequisite
As a prerequisite you will need to install the following packages,these packages are build tools and libraries you will need for compilation process.

sudo apt-get -y install libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline5-dev zlib1g-dev

Installing Ruby 1.9.1

cd ~
mkdir src
cd src/
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
tar xzvf ruby-1.9.1-p0.tar.gz
cd ruby-1.9.1-p0/
wget http://redmine.ruby-lang.org/attachments/download/237
patch -p1 < 237
./configure --prefix=/usr/local --with-openssl-dir=/usr --with-readline-dir=/usr --with-zlib-dir=/usr 
sudo make && sudo make install

To make sure form your ruby version use the following command line.

ruby -v

The output should be something like this

ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]

If this command only returns “Happy new Ruby” please feel comfortable, your instllation is going fine.

ruby -ropenssl -rzlib -rreadline -e "puts 'Happy new Ruby'"

Ruby 1.9 bundles rubygems so there is no need to install it.

Installing mysql-ruby adaptor

cd ~/src
wget http://rubyforge.org/frs/download.php/51087/mysql-ruby-2.8.1.tar.gz
tar xzvf mysql-ruby-2.8.1.tar.gz
cd mysql-ruby-2.8.1
sudo ruby extconf.rb
make
sudo make install

Installing rails and other stuff

sudo gem install rails rake rack sqlite3-ruby

To make sure that all packages are successfully installed use the following command line

gem list

The output should be something like this

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
rack (0.9.1)
rails (2.3.2)
rake (0.8.4)
sqlite3-ruby (1.2.4)

Now you can create and run a new rails application working on ruby 1.9 “.

For mysql database

rails yourapp --database=mysql

For sqlite3

rails yourapp
rubyonrails 2.3

rubyonrails 2.3

With best wishes for fast performance.