To install on a Unix-based system like Solaris or Linux, you can go to the download page at http://www.ruby-lang.org. You can then use the instructions described here: http://www.rubycentral.com/faq/rubyfaq-3.html. (Step 3, Compiling Ruby.)
Those instructions work well when installing to the standard location (/usr/local/bin), but if you need to install to a non-standard location, follow the instructions below.
Acknowledgments:
This information was gleaned from a post made by Ara Howard in
2004, that he kindly forwarded to me in 2006. (Nicholas
Sterling was also helpful in making sense of the process.)
--eric Armstrong
Once Ruby has been installed, you'll want to see about InstallingRubyGems?. After you've done that, installing extensions created by others is a breeze.
#################
# Get a recent version of the gnu C compiler (gcc)
# and make sure it is on your path.
#
# Lacking that, you see an error like this:
# gcc: installation problem, cannot exec `cpp':
# No such file or directory
#################
# Clear out a previous build (if any)
# and create config.h, specifying the target location
#
make distclean
./configure --prefix=/wherever/you/want
#################
# Set the values you need when compiling.
#
# LD_LIBRARY_PATH tells where to find modules
# that need to be linked in during the build.
#
# LD_RUN_PATH will be compiled into the binary, so
# the program knows where to find modules at
# runtime without having to set LD_LIBRARY_PATH.
#
sh: export LD_RUN_PATH=/wherever/you/want/lib/
export LD_LIBRARY_PATH=/wherever/you/want/lib/
csh: setenv LD_RUN_PATH /wherever/you/want/lib/
setenv LD_LIBRARY_PATH /wherever/you/want/lib/
#################
# Compile without installing, then install binaries & docs.
#
make
make install
make install-docs
Notes: