Install these packages:
$ apt-get install build-essential zlib1g zlib1g-dev \
libreadline6 libreadline6-dev libssl-dev libyaml-dev \
libffi-dev libgdbm-dev libx11-dev aptitude libtidy-dev \
libxml2-dev libevent-dev libev-dev autoconf
Then use rbenv to install the patched package:
curl https://raw.github.com/gist/4135896/bb2172419767bd8bb324d1fb27df1e8f9b56668c/rbenv.sh | sh ; rbenv global 1.9.3-p194-perf
It has some minor fixes/advantages over the original one by @burke: The hashes after the package urls (checksums fail otherwise):
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
And additional CFLAGS for the Rackspace servers:
make -j 8 CFLAGS="-O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -fPIC -march=barcelona -pipe"
I added two files without the CFLAGS if you don't want that:
curl https://raw.github.com/gist/4135896/a7cf8d277e8c1537990a782ecc8febc987c47d58/zrbenv_no_cflags.sh | sh ; rbenv global 1.9.3-p194-perf