当前位置: 移动技术网 > IT编程>脚本编程>Ruby > CentOS 6.3下编译安装Ruby 2.0笔记

CentOS 6.3下编译安装Ruby 2.0笔记

2017年12月08日  | 移动技术网IT编程  | 我要评论

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库文件,以下为该补丁文件打包下载地址

本地下载
详见:
解决方法:

复制代码 代码如下:

# 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~

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网