Install System Prerequisites

Install the prerequisite development headers. If this is a production system, make note of all the packages installed, for future removal.

yum install apr-devel.x86_64 apr-util-devel.x86_64 curl-devel.x86_64 gcc-c++.x86_64 httpd-devel.x86_64 mysql-devel.x86_64 mysql-server.x86_64 openssl-devel.x86_64 zlib-devel.x86_64

Install Ruby Enterprise Edition

First, install the End Point yum repository:

yum update m2crypto
curl -O
yum --nogpgcheck install endpoint-repo-1.0-1.x86_64.rpm

Next, install Ruby and RubyGems:

yum install ruby-enterprise ruby-enterprise-rubygems

Install Phusion Passenger (mod_rails)

First, install the Phusion-provided Passenger repository for CentOS:

curl -O
yum --nogpgcheck install passenger-release.noarch.rpm

Next, install Passenger:

gem install passenger

Configure Apache

nano /etc/httpd/conf.d/mod_rails.conf
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/
nano /etc/httpd/conf.d/myrailsapp.conf
<VirtualHost *:80>
	DocumentRoot /var/www/myrailsapp/public
	ErrorLog /var/www/myrailsapp/log/error_log
	CustomLog /var/www/myrailsapp/log/access_log common
	# mod_rails
	<Directory /var/www/myrailsapp/public>
		Options -Multiviews
service httpd restart

Install Rails via Bundler

gem update --system
gem install bundler
gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config
cd /var/www/myrailsapp
bundle install --without development test
touch log/production.log
chgrp apache log/*
chmod g+w log/*

Remove Development Packages

If you just deployed to a production environment, you probably don’t want compilers, development libraries, headers or packagers leaving you vulnerable to a rootkit exploit:

yum remove *-devel *-headers gcc-c++ cpp gcc libgomp pkgconfig