CentOS 6.3下編譯安裝Ruby 2.0

LINUX操做系統: CentOS6.3 64bitlinux

Ruby: ruby-2.0.0-p247c++

一.安裝開發包(使用默認CENTOS更新源):ruby

# yum install openssl* openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-devel curl-devel expat-devel gettext-devel curl


二.關閉iptables和SELINUXide

# service iptables stopthis

# setenforce 0google

# vi /etc/sysconfig/selinuxurl

---------------spa

SELINUX=disabled操作系統

---------------


三.安裝Ruby

# wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz

# tar zxvf ruby-2.0.0-p247.tar.gz

# cd ruby-2.0.0-p247

# ./configure --enable-shared --enable-pthread --prefix=/usr/local/ruby

# make && make install


編譯時報錯

———————————————————————————

ossl_pkey_ec.c:815: error: ‘EC_GROUP_new_curve_GF2m’ undeclared (first use in this function)

————————————————————————————

google後找到官方的一個解決補丁,也就是替換兩個ssl庫文件,附件爲該補丁文件打包下載地址

詳見:https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/41808

解決方法:

# cd ruby-2.0.0-p247

# wget --no-check-certificate https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/41808/raw/ext/openssl/ossl_pkey_ec.c

# wget --no-check-certificate https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/41808/raw/test/openssl/test_pkey_ec.rb

# mv ext/openssl/ossl_pkey_ec.c  ext/openssl/ossl_pkey_ec.c.bak

# cp ossl_pkey_ec.c ext/openssl/

# mv test/openssl/test_pkey_ec.rb test/openssl/test_pkey_ec.rb.bak

# cp test_pkey_ec.rb  test/openssl/

從新編譯:

# make && make install


四.將ruby命令集加入系統環境變量

# echo "PATH=$PATH:/usr/local/ruby/bin;export PATH" >> /etc/profile

# source /etc/profile


五.檢查ruby版本

# ruby -v

——————————————————————————

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

——————————————————————————


# gem --version

——————————————————————————

2.0.3

——————————————————————————


# irb

——————————————————————————

irb(main):001:0> 3+5

=> 8

irb(main):002:0> puts "hello world!"

hello world!

——————————————————————————


大功告成 O(∩_∩)O~

相關文章
相關標籤/搜索