Installing Your Own Ruby
From OCS Support Wiki
Contents |
Introduction
This guide will show you how to install your own local install of Ruby, so that you can control the version of it and exactly what gems are installed.
If you plan to use this with Ruby with Rails, you can only use Mongrel, as mod_rails / Passenger uses the system-wide Ruby we have installed.
Please Note: It is not necessary to do this to use Ruby on our systems, as we have it installed already. The instructions are for people who wish to maintain their own copy of Ruby with the exact gems they want.
Compile and Install
In the below commands, if you want to use a different version of Ruby, simply replace ruby-1.9.1-p243 with whatever version you want.
cd mkdir ruby mkdir sources cd sources wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.bz2 tar xfz ruby-1.9.1-p243.tar.bz2 rm -f ruby-1.9.1-p243.tar.bz2 cd ruby-1.9.1-p243
Now Ruby is ready to be compiled. In the below example, replace ocs with your cPanel/FTP username:
./configure --prefix=/home/ocs/ruby make make install cd
If you get any errors during this part, we may have to turn off your jail shell. Please contact us to do so.
Edit the file ~/.bashrc:
nano ~/.bashrc
At the bottom, add:
PATH=$HOME/ruby/bin:$PATH:$HOME/bin export PATH
Save the file, exit your shell, and login again via SSH.
Ruby Gems
Now you need to install your own Ruby Gems:
cd cd sources wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz tar xfz rubygems-1.3.5.tgz rm -f rubygems-1.3.5.tgz cd rubygems-1.3.5 ~/ruby/bin/ruby setup.rb
Once installed, you can run:
gem list --local
to confirm there are no gems installed. This is the correct result. If there are gems installed, you are using our Ruby and something has gone wrong. To fix this, delete the ruby directory in your home directory entirely and repeat this guide again.
Now you can install whatever gems you want locally, for example:
gem install rails mongrel
will install Rails and Mongrel. Note that their binaries will be put in ~/ruby/bin/*, so if you run mongrel_rails it will be ran first from your local directory instead of our system-wide installation.
Cleanup
If you wish to save disk space on your account, you can remove the sources directory, as it is no longer needed:
cd rm -Rf sources
