I couldn't find any decent guides on how to install Rails 3 on RHEL 6 so here it is. This also works on Centos 6 of course. We'll be using Apache with Phusion Passenger (mod_rails). This is an apache module that will serve up Rails applications in a similar way to how PHP is handled.
You can skip this on Centos, but for RHEL you need to log into RHN or your Satellite server and enable the optional server repo for your machine (required for ruby-devel and rubygems).
Install the required development packages.
yum install gcc gcc-c++ make curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel
Install ruby, ruby-devel, and rubygems:
yum install ruby ruby-devel rubygems
Next, use gems to install Rails and Passenger. (Note this takes a while.)
gem install rails passenger
Build the Passenger apache module by running:
That will also give you some relevant instructions on how to configure Apache. Now let's create a test application.
cd /var/www/htmlEdit Gemfile and add:
rails new railstest
Generate our hello world controller:
rails generate controller hello
Edit config/routes.rb and uncomment the next to last line
match ':controller(/:action(/:id(.:format)))'Edit app/views/hello/index.html.erb add some hello world text.
At this point you can test the application to make sure it works with the default rails server. Run rails server and open http://hostaddress:3000/hello and you should see your hello world text. Kill this and proceed with your apache configuration.
This assumes you have a default httpd install. Change this accordingly if you already have other vhosts configured. (Note the RailsEnv option, you'll need to set this accordingly in the future)
Add the following to /etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.soRestart apache, browse to http://hostaddress/hello and you should see your hello world text!