Ruby on Rails installation on Centos

Ruby on Rails (ROR) installation

Ruby on Rails is a web application framework that runs via Ruby programming language. It helps developers to create a variety of web applications. In this section we cover Ruby on Rails installation without using RVM. RVM means Ruby Version Manager which helps us to install multiple versions of Ruby on same server without any conflict, also with RVM we can easily switch to different version of Ruby.In order to complete installation we need the following components:


During ROR installation, first we need to update packages installed in our system and then we can proceed with Ruby installation along all dependencies. You can use following command for package updates. Please note, for installation process you should be logged in as root user.

[root@Hostdire ~]# yum update

Note: When we try to install a package using yum, it will list all 32 and 64bit packages and will automatically install in our system if we choose “-y” option, but actually we need only those packages as per our system architecture.To know your system architecture run any one of the following commands.

[root@Hostdire ~]# arch
[root@Hostdire ~]# uname -r
[root@Hostdire ~]# getconf LONG_BIT

We can easily install ruby using yum, but I would prefer to install from source. Before proceeding with Ruby compilation we need to install some prerequisites.Following command will help you to meet the requirements.

[root@Hostdire ~]# yum install httpd mysql mlocate  zlib ntp gcc g++ autoconf make automake bison bzip2 readline

[root@Hostdire ~]# yum install httpd-devel sqlite-devel mysql-devel curl-devel apr-util-devel apr-devel manlibxml2-devel libxslt-devel libffi-devel iconv-devel zlib-devel readline-devel openssl-devel

Now we can proceed with ROR installation.Install yaml

[root@Hostdire ~]# cd /opt
[root@Hostdire ~]# wget
[root@Hostdire ~]# tar -xzvf yaml-0.1.4.tar.gz
[root@Hostdire ~]# cd yaml-0.1.4
[root@Hostdire ~]# ./configure –prefix=/usr/local
[root@Hostdire ~]# make
[root@Hostdire ~]# make install

Here we have completed the installation of yaml and now we are moving forward with Ruby installation. First, download the latest Ruby package from corresponding source and proceed with installation. In this tutorial I have used the ruby version 1.9.3-p0. You can follow the steps given below to complete the installation process.

[root@Hostdire ~]# cd /opt/
[root@Hostdire ~]#wget
[root@Hostdire ~]#tar xvzf ruby-1.9.3-p0.tar.gz
[root@Hostdire ~]#cd ruby-1.9.3-p0
[root@Hostdire ~]#./configure
[root@Hostdire ~]#make
[root@Hostdire ~]#make install

Ruby version can be verified using the command:

[root@Hostdire ~]# ruby –version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

Now we have successfully installed Ruby, it’s the time to install and update the gems on your server to latest version. The below commands will help you to accomplish the same.

[root@Hostdire ~]# cd /opt
[root@Hostdire ~]# wget
[root@Hostdire ~]# tar xvzf rubygems-1.8.24.tgz
[root@Hostdire ~]# cd rubygems-1.8.24
[root@Hostdire ~]# ruby setup.rb
[root@Hostdire ~]# gem update –-system

Finally, we need to install the gem module rails. You can install it by issuing the following command.

[root@Hostdire ~]# gem install rails

To verify everything is done correctly, use the command “gem list”

[root@Hostdire ~]# gem list

I have installed Ruby along with Apache Phusion passenger, so I am including the Phusion passenger installation as well. Phusion passenger installation is pretty simple and we can complete it in few steps.

Install Passenger
[root@Hostdire ~]# gem install passenger

If you would like to install a specific version of passenger then you can use below command:

[root@Hostdire ~]#gem install passenger -v <version>

For example, if you are planning to install passenger version 3.0.17 then use the command listed below

[root@Hostdire ~]# gem install passenger -v 3.0.17

Then we need to install passenger apache2 module.

[root@Hostdire ~]# passenger-install-apache2-module

After the completion of second command you will get an output similar to the one given below.

The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /opt/ruby/lib/ruby/gems/1.9.1/gems/passenger-4.0.17/buildout/apache2/
PassengerRoot /opt/ruby/lib/ruby/gems/1.9.1/gems/passenger-4.0.17
PassengerDefaultRuby /opt/ruby/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific

Press ENTER to continue.

Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

<VirtualHost *:80>
# !!! Be sure to point DocumentRoot to ‘public’!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews

And that’s it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

/opt/ruby/lib/ruby/gems/1.9.1/gems/passenger-4.0.17/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion ( ) :-)

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.


After this create a new passenger.conf file under the folder /etc/httpd/conf.d/ and add details related to passenger LoadModule, PassengerRoot and PassengerRuby specified in the output of passenger-install-apache2-module.

LoadModule passenger_module /opt/ruby/lib/ruby/gems/1.9.1/gems/passenger-4.0.17/buildout/apache2/
PassengerRoot /opt/ruby/lib/ruby/gems/1.9.1/gems/passenger-4.0.17
PassengerDefaultRuby /opt/ruby/bin/ruby

Once it’s completed you have Ruby on Rails installed on your server.

If you have any questions please feel free to contact us.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts