How to install Ruby on Rails on Centos 6

I’ve had trouble finding a decent guide on installing Ruby in Centos 6. There are a few good guides out there but none quite did the trick for me, whether it’s changes in Centos or just a different system setup I don’t know but this is what worked for me.

Prerequisites


yum update
yum -y groupinstall "Development Tools"
yum -y install ntp zlib zlib-devel sqlite-devel httpd mysql-server mysql-devel curl-devel httpd-devel apr-devel apr-util-devel mlocate manlibxml2-devel libxslt-devel libffi-devel readline-devel

Install rvm


sudo curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable

source /etc/profile.d/rvm.sh

Install ruby, gems and rails


rvm install 1.9.3

rvm use 1.9.3 --default

ruby --version

gem install rails

Install Passenger


gem install passenger

passenger-install-apache2-module

The final command will output something like the below, just do as it suggests.



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

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.17/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.17
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p448/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
configuration!

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:
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /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:

/usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.17/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) <img src="http://www.tiag.me/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /> 

https://www.phusionpassenger.com

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

Like this Article? Share it!

About the Author

Author Gravatar
Andy

Andy has been in IT support in the academic industry for over 7 years now, with an in-depth knowledge of both Windows and Unix based systems.

Related Posts

4 Comments

  1. Am I correct that RVM generally installs only for individual users and not all users? I.e. it installs in a user’s directory and not a system directory?

    I like the layout of your instructions. Very nice indeed.

    Nelson

    • Hi Nelson,

      Thanks, glad you like the layout :) I try to make the guides as easy to read as possible – no ones like a wordy guide.

      As for RVM, I think in this case it’s on the system. For ease I tend to do things as root, especially in this case where it was for a user who I didn’t want to have sudo access.

      Andy

  2. Hi Andy,

    How about installing RoR with rbenv and phusion passenger?

    Thanks.

  3. Thanks for this; I think I might have finally found a working tutorial. :D

Leave a Comment