On my webserver I'm still using Ruby 1.8.4 as that is what Ubuntu has in their software repository, however it is quite old (December 2005). I wanted to put 1.8.6 on there as that's the latest and I prefer using newer versions of software, but I wanted to keep the existing one incase there were any problems, so I installed it into my home directory. Here are the steps I took to get it set up.
Apparently Ruby needs a supportive application called readline, so first we will do that.
wget ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
tar zxf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=/home/spidah/bin
make
make install
Once that is complete you can grab and install ruby:
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
tar zxf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure --prefix=/home/spidah/bin --enable-pthread --with-readline-dir=/home/spidah/bin
make
make install
make install-doc
You will need to make sure that the
bin directory is in your path (mine turns out to be
/home/spidah/bin/bin). To do this just edit your
~/.bash_profile file and add
PATH=~/bin/bin:"${PATH}"to the bottom. Now you can either source your profile (
source ~/.bash_profile) or close the console and open a new one. Once you have done that running
ruby -v
should return
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
or similar. You can also check that it's finding it in the correct location by running
which ruby
If you want OpenSSL support then you need to do a little bit extra. From within the ruby-1.8.6 directory do:
cd ext/openssl
ruby extconf.rb
touch *.o
make
make install
I don't know which
.o file needed to be touch for make to build, but it was just easy to touch them all.
As I was changing to a newer Ruby version and also putting it in a different location, I thought it was easier to also install rubygems in the new location so that everything is in the same place. I'm not sure if it could be used from the original location, but I'm not really bothered.
wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tar zxf rubygems-0.9.2.tgz
cd rubygems-0.9.2
ruby setup.rb
and that's it! I also wanted to copy all my gems over, so I did this:
cd /usr/lib/ruby/gems
cp -r 1.8 /home/spidah/bin/lib/ruby/gems
and waited for that to finish. Once it was done I could go into one of my rails apps and boot the mongrel server without any problems.