在CentOS上编译安装Ruby 1.9

删除已经安装的项目:

1yum erase ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs

安装依赖:

1yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel

下载Ruby源码并解压缩:

1cd ~/Downloads  #进入下载目录
2lftp ftp.ruby-lang.org
3lftp ftp.ruby-lang.org:/> cd /pub/ruby
4lftp ftp.ruby-lang.org:/pub/ruby>
5lftp ftp.ruby-lang.org:/pub/ruby> get ruby-1.9.3.pXXX.tar.gz  # 2012-08-26,XXX为194 
6lftp ftp.ruby-lang.org:/pub/ruby> exit
7tar zxvf ruby-1.9.3.pXXX.tar.gz

编译安装:

1cd ruby-1.9.3.pXXX
2./configure
3make && make install

检查安装:

1ruby -v
2ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

参考文章: