欢迎访问www.showerlee.com, 您的支持就是我前进的动力.

CentOS 6.3下编译安装Ruby 2.0

showerlee 2014-04-10 16:58 RUBY 阅读 (22,587) 5条评论

LINUX操作系统: CentOS6.3 64bit

Ruby: ruby-2.0.0-p247

一.安装开发包(使用默认CENTOS更新源):

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

二.关闭iptables和SELINUX

# service iptables stop

# setenforce 0

# vi /etc/sysconfig/selinux

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

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~

正文部分到此结束
版权声明:除非注明,本文由(showerlee)原创,转载请保留文章出处!
本文链接:http://www.showerlee.com/archives/1123

继续浏览:ruby

5条大神的评论

loading
  1. 沙发
    Torres2014年11月24日下午8:40 回复

    按照你的方法,编译ruby报错

    ossl_pkey_ec.c:1: error: expected identifier or ‘(’ before ‘<’ token
    ossl_pkey_ec.c:5: error: expected identifier or ‘(’ before ‘)’ token
    ossl_pkey_ec.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
    ossl_pkey_ec.c:5: error: expected identifier or ‘(’ before ‘<’ token
    ossl_pkey_ec.c:6: error: expected identifier or ‘(’ before ‘)’ token
    ossl_pkey_ec.c:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
    ossl_pkey_ec.c:6: error: expected identifier or ‘(’ before ‘)’ token
    ossl_pkey_ec.c:6: error: expected identifier or ‘(’ before ‘{’ token
    ossl_pkey_ec.c:6: error: expected identifier or ‘(’ before ‘<’ token
    ossl_pkey_ec.c:12:11: warning: character constant too long for its type
    ossl_pkey_ec.c:12:32: warning: character constant too long for its type
    ossl_pkey_ec.c:20:47: warning: character constant too long for its type
    ossl_pkey_ec.c:20: error: expected identifier or ‘(’ before ‘)’ token
    ossl_pkey_ec.c:22: error: expected identifier or ‘(’ before ‘<’ token
    ossl_pkey_ec.c:96:3: warning: character constant too long for its type
    ossl_pkey_ec.c:98: error: expected identifier or ‘(’ before ‘<’ token
    ossl_pkey_ec.c:111: error: expected identifier or ‘(’ before numeric constant
    make[2]: *** [ossl_pkey_ec.o] Error 1
    make[2]: Leaving directory `/data/soft/ruby-2.0.0-p247/ext/openssl'
    make[1]: *** [ext/openssl/all] Error 2
    make[1]: Leaving directory `/data/soft/ruby-2.0.0-p247'
    make: *** [build-ext] Error 2

  2. 板凳
    zong2015年8月14日下午8:03 回复

    一楼的问题我也遇到了,怎么解决的呢?

    • showerlee2015年8月21日下午1:37 回复

      @zong 应该是RUBY的依赖问题,试试这个
      yum install patch gcc-c++ make bzip2 autoconf automake libtool bison iconv-devel readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel
      然后去编译目录make clean, 重新编译一遍.

发表评论

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif