How to install Ruby on Rails on CentOS 6.4

Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features.

Before installing Ruby on our machine we have to update our system and have to install some dependency applications.

点击(此处)折叠或打开

  1. yum -y update
  2. yum groupinstall "Development Tools"

Now we can proceed for Ruby installation
Download and install ruby as below step 

点击(此处)折叠或打开

  1. cd /opt/
  2. wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
  3. tar xvzf ruby-2.0.0-p247.tar.gz
  4. cd ruby-2.0.0-p247
  5. ./configure
  6. make
  7. make install

After completing the installation verify the ruby version: 

点击(此处)折叠或打开

  1. ruby -v
Now we will download and install rubygem 

点击(此处)折叠或打开

  1. cd /opt/
  2. wget http://production.cf.rubygems.org/rubygems/rubygems-2.0.6.tgz
  3. tar xvzf rubygems-2.0.6.tgz
  4. cd rubygems-2.0.6
  5. ruby setup.rb

Now we will ensure that we have the latest gem with us by issuing below command: 

点击(此处)折叠或打开

  1. gem update --system

Output:

点击(此处)折叠或打开

  1. Latest version currently installed. Aborting.

Now we will install latest version of rails with it’s dependencies:

点击(此处)折叠或打开

  1. gem install rails
Verify the installed gems 

点击(此处)折叠或打开

  1. gem list

转自:http://www.linuxfunda.com/2013/08/05/how-to-install-ruby-on-rails-on-centos-6-4/

注意事项:
1.yum -y update命令升级系统已安装包耗时太长,可以跳过
2.ruby版本可以自由从官网选择最新ruby版本下载,安装文档中的版本在make时会报错,最新的官网版本已修复该bug:
ossl_pkey_ec.c:766:17: warning: implicit declaration of function ‘EC_GF2m_simple_method’ [-Wimplicit-function-declaration]
                 method = EC_GF2m_simple_method();
                 ^
ossl_pkey_ec.c:766:24: warning: assignment makes pointer from integer without a cast [enabled by default]
                 method = EC_GF2m_simple_method();
                        ^
ossl_pkey_ec.c:821:29: error: ‘EC_GROUP_new_curve_GF2m’ undeclared (first use in this function)
                 new_curve = EC_GROUP_new_curve_GF2m;
                             ^
ossl_pkey_ec.c:821:29: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [ossl_pkey_ec.o] Error 1
make[2]: *** Waiting for unfinished jobs....
checking ../.././parse.y and ../.././ext/ripper/eventids2.c
installing default ripper libraries
compiling init.c
make[2]: Leaving directory `/tmp/ruby-build.20131031165127.5126/ruby-2.0.0-p247/ext/openssl'
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
3.rubygems可以从官网选择最新版本


09-04 06:25