This article will guide you through the installation of Ruby on Rails in a linux machine. As you are aware Ruby on Rails made a splash with its simplicity and ease of use for devoloping web applications.

What is Ruby?

Ruby is a pure object-oriented programming language with a super clean syntax that makes programming elegant and fun. Ruby successfully combines Smalltalk’s conceptual elegance, Python’s ease of use and learning, and Perl’s pragmatism. Ruby originated in Japan in the early 1990s, and has started to become popular worldwide in the past few years as more English language books and documentation have become available.

What is Rails?

Rails is an open source Ruby framework for developing database-backed web applications. Rails is designed from the ground up to create dynamic Web sites that use a relational database backend. It adds key words to the Ruby programming language that make Web applications easier to configure. In addition, it’s designed to automatically generate a complete, if somewhat crude, Web application from an existing database schema. The latter is both Ruby’s greatest strength and its Achilles’ heel. Rails makes assumptions about database schema naming conventions that, if followed, make generating a basic Web site a matter of executing single command.

Installing the Software on CentOS

1. Install Ruby

Need to install the testing repository so add a file named “testing” to the directory /etc/yum.repos.d/ That will allow you to rock ruby 1.8.4.


# packages in testing

[testing]

name=CentOS-$releasever - Testing

baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/

gpgcheck=1

enabled=1

gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

Now you can use yum to install ruby 
yum update

yum install ruby ruby-devel ruby-libs irb rdoc

2. Install Gem


cd /usr/local/src

wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz

tar -xvzf rubygems-0.8.11.tgz

cd rubygems-0.8.11

ruby setup.rb

cd ..

3. Install fast-cgi


cd /usr/local/src

wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz

tar xzvf fcgi-2.4.0.tar.gz

cd fcgi-2.4.0

./configure

make

make install

cd ..

4. Install fast-cgi Bindings

 
cd /usr/local/src

wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz

tar zxvf ruby-fcgi-0.8.6.tar.gz

cd ruby-fcgi-0.8.6

ruby install.rb config

ruby install.rb setup

ruby install.rb install

cd ..

5. Install Rails

gem install rails –include-dependencies

Ruby and Rails on Red Hat Enterprise Linux

Make sure you have installed zlib-devel installed otherwise Gem will fail.
up2date zlib-devel

First you need to install ruby installed using rpm’s from the machine.
To determine which all rpm’s installed


rpm -qa | egrep '(ruby)|(irb)'

To uninstall the installed ruby rpm’s


rpm -e ruby-docs-1.8.1-7.EL4.2 \

ruby-1.8.1-7.EL4.2 \

irb-1.8.1-7.EL4.2 \

ruby-libs-1.8.1-7.EL4.2 \

ruby-mode-1.8.1-7.EL4.2 \

ruby-tcltk-1.8.1-7.EL4.2 \

ruby-devel-1.8.1-7.EL4.2

Install Ruby from source


wget ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.4.tar.gz

tar xvzf ruby-1.8.4.tar.gz

cd ruby-1.8.4

./configure --prefix=/usr

make

make install

Install Ruby Gems


wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz

tar xvzf rubygems-0.8.11.tgz

cd rubygems-0.8.11

ruby setup.rb

Install Rails


cd

gem update

gem update --system

rm `gem env gempath`/source_cache

rm -f ~/.gem/source_cache

gem update

gem install rails --include-dependencies

Now configuring mod_fastcgi Apache (1.3) config file httpd.conf

1. Install mod_fcgi module


curl -O http://fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz

or


wget http://fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz

tar xvfz mod_fastcgi-2.4.2.tar.gz

cd mod_fastcgi-2.4.2

/usr/local/apache/bin/apxs -cia mod_fastcgi.c

2. Configuring httpd.conf


LoadModule fastcgi_module modules/mod_fastcgi.so



AddHandler fastcgi-script .fcgi .fcg .fpl



service httpd restart


3. Edit the .htaccess file


change /dispatch.cgi to /dispatch.fcgi

4. This server has been upgraded to MySQL 4.1

The default Ruby mysql driver will not connect because it is running in old_password compatibility mode (otherwise Ensim cannot connect). In order to fix it we need to reinstall the mysql-ruby client


wget http://www.tmtm.org/en/mysql/ruby/mysql-ruby-2.5.tar.gz

tar vxzf mysql-ruby-2.5.tar.gz

cd mysql-ruby-2.5

ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config

5. Edit your .htaccess with following entries


#Set to development, test, or production

DefaultInitEnv RAILS_ENV production



 Options Indexes ExecCGI FollowSymLinks



RewriteEngine On

RewriteRule ^$ index.html [QSA]

RewriteRule ^([^.]+)$ $1.html [QSA]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Live
  • StumbleUpon
  • Twitter
  • Yahoo! Buzz
  • Reddit
  • Technorati