Mohammad Kotb

"Talk is cheap. Show me the Code" -Linus Torvald

Ruby On Rails environment on Ubuntu 10.04

Posted by mohammadkotb on June 21, 2010

Hi,

I think this is my first technical post in the blog, so today I faced some problems while building the Ruby on Rails environment on my machine. I just like sharing this knowledge with you.

First, in this post we will make the following:

  1. Ruby 1.9.1
  2. Rails 2.3.5
  3. Thin server.
  4. MySQL server.

1. Ruby 1.9.1
The following commands mainly download the Ruby source code and compile it and so on

Just you have to install the following libraries:
sudo apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev

move to /usr/local/src to download source code and compile it in this folder
cd /usr/local/src

Download the source code, and unpack it
sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
sudo tar xzf ruby-1.9.1-p0.tar.gz
cd ruby-1.9.1-p0

Now, you have to check the version of gcc if it is 4.4 some errors will occur
dpkg -l | grep gcc

if gcc 4.4 found then you have to edit the cont.c file to go on. Open it up, and change the lines 90, 270 and 317 from #elif to #else.
sudo gedit cont.c

then write the following commands in terminal
sudo ./configure –prefix=/usr/local/ruby-1.9.1
sudo make
sudo make install

After these steps you have finally installed Ruby 1.9.1, to check its version
cd /usr/local/ruby-1.9.1/bin
ruby -v
output like that: ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]

Now, the ruby commands such as ruby, rake, irb, … etc are accessed only from /usr/local/ruby-1.9.1/bin, and all the commands are found in /usr/local/bin so just make link for the commands in ruby-1.9.1/bin and put them in /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/ruby /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rake /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/gem /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/irb /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/ri /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rdoc /usr/local/bin

2. Rails 2.3.5
Now, Ruby 1.9.1 is installed successfully on your machine, just add this command to terminal to install the Rails 2.3.5 gem
sudo gem install rails -v=2.3.5

3. Thin server
Also to install Thin application server gem
sudo gem install thin

Then lets make links for the the recently installed commands
sudo ln -s /usr/local/ruby-1.9.1/bin/rails /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rakeup /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/thin /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/testrb /usr/local/bin

4. MySQL server
Finally to install MySQL server for DB
sudo apt-get install mysql-server
and while installing it is required to set the root password

References: http://labnotesh.wordpress.com/2009/04/28/compiling-ruby-19-with-gcc-4/

Hope that it is some how useful for you
Enjoy :)

2 Responses to “Ruby On Rails environment on Ubuntu 10.04”

  1. Thanks for your posting I actually just used your same setup for 1.9.2RC2 to help me get the rails beta installed.

  2. YaKhOo said

    hello
    i know that long time but following ur steps i get this error

    root@BBXkhOu:/usr/local/src/ruby-1.9.1-p0# ./configure –prefix=/usr/local/ruby-1.9.1
    configure: error: invalid variable name: –prefix

    i have try without the dash ” – ” save the trick

    cHouKraN”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.