Tuesday, November 26, 2013

Installing Ruby on Rail on Centos 6 (64 bit) Virtual Machine

Ruby on Rails


Prerequisites

  • Ruby language version 1.9.3 or newer
  • The RubyGems packaging system
  • A working installation of the SQLite3 Database

  • On my development environment, I used centos 6 64 bit minimal (no GUI) operating system to run ruby on rails. I installed it on Oracle Virtualbox.

    Step 1: Install the Ruby
    Check the ruby version.
    [root@centosAshley02 ~]# ruby -v
    -bash: ruby: command not found
    
    No found command means we have to intall ruby.
    Install the wget command to download source files
    [root@centosAshley02 ~]# yum install wget
    
    Download rpm and update the system
    [root@centosAshley02 ~]# cd /tmp/
    [root@centosAshley02 ~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    [root@centosAshley02 ~]# rpm -Uvh epel-release-6-8.noarch.rpm
    [root@centosAshley02 ~]# yum -y update
    
    [root@centosAshley02 ~]# yum -y groupinstall "Development Tools"
    [root@centosAshley02 ~]# yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
     
    
    Get the latest ruby version using wget command
    [root@centosAshley02 ~]# cd /usr/src/
    [root@centosAshley02 ~]# wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz
    [root@centosAshley02 ~]# tar zxvf ruby-2.0.0-p353.tar.gz
    [root@centosAshley02 ~]# cd ruby-2.0.0-p353
    [root@centosAshley02 ~]# ./configure
    [root@centosAshley02 ~]# make
    [root@centosAshley02 ~]# make install
    
    Show the ruby version.
    [root@centosAshley02 ~]# ruby -v
    ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
    
    Step 2: Install the Rubygems
    [root@centosAshley02 ~]# cd /usr/src/
    [root@centosAshley02 src]# wget http://production.cf.rubygems.org/rubygems/rubygems-2.1.7.tgz
    [root@centosAshley02 src]# tar zxvf rubygems-2.1.7.tgz
    [root@centosAshley02 src]# cd rubygems-2.1.7
    [root@centosAshley02 rubygems-2.1.7]# /usr/local/bin/ruby setup.rb
    
    Check the rubygem installation, the back to parent directory
    [root@centosAshley02 rubygems-2.1.7]# gem -v
    2.1.7
    [root@centosAshley02 rubygems-2.1.7]# cd
    
    Step:3 Install Sqlite
    If you don't have curl then execute the following
    [root@centosAshley02 ~]# yum install curl
    
    Install rvm
    curl -L get.rvm.io | bash -s stable
    
    Source the file rvm.sh
    source /etc/profile.d/rvm.sh
    
    for me to check, I type.
    [root@centosAshley02 ~]# rvm requirements
    Checking requirements for centos.
    Requirements installation successful.
    
    Step 4: Sqlite
    [root@centosAshley02 ~]# cd /opt/
    [root@centosAshley02 opt]# wget http://www.sqlite.org/2013/sqlite-autoconf-3080100.tar.gz
    [root@centosAshley02 opt]# tar xvzf sqlite-autoconf-3080100.tar.gz
    [root@centosAshley02 opt]# ln -s /opt/sqlite-autoconf-3080100/ /opt/sqlite3
    [root@centosAshley02 opt]# cd sqlite3/
    [root@centosAshley02 opt]# ./configure --prefix=/opt/sqlite3
    
    Configure the .bashrc
    [root@centosAshley02 ~]# vi .bashrc
    
    add on the .bashrc LD_LIBRARY_PATH=/usr/local/lib64 then source and test the varibale
    [root@centosAshley02 ~]# source .bashrc
    [root@centosAshley02 ~]# echo $LD_LIBRARY_PATH
    /usr/local/lib64
    [root@centosAshley02 ~]# export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
    
    Then make and make install
    [root@centosAshley02 ~]# cd /opt/sqlite3
    [root@centosAshley02 sqlite3]# make
    [root@centosAshley02 sqlite3]# make install
    
    Test the sqlite,
    [root@centosAshley02 ~]# mkdir -p /usr/local/sqlite/var
    [root@centosAshley02 ~]# sqlite3 /usr/local/sqlite/var/testdb
    SQLite version 3.6.20
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite>
    

    Then .exit, for more info type .help
    Step 5: Install the rails
    This may take time. Please be patient.
    [root@centosAshley02 ~]# gem install rails
    
    Check the gems installed.
    [root@centosAshley02 ~]# gem list
    
    *** LOCAL GEMS ***
    
    actionmailer (4.0.1)
    actionpack (4.0.1)
    activemodel (4.0.1)
    activerecord (4.0.1)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.1)
    arel (4.0.1)
    atomic (1.1.14)
    bigdecimal (1.2.0)
    builder (3.1.4)
    bundler (1.3.5)
    erubis (2.7.0)
    hike (1.2.3)
    i18n (0.6.5)
    io-console (0.4.2)
    json (1.7.7)
    mail (2.5.4)
    mime-types (1.25.1)
    minitest (4.3.2)
    multi_json (1.8.2)
    polyglot (0.3.3)
    psych (2.0.0)
    rack (1.5.2)
    rack-test (0.6.2)
    rails (4.0.1)
    railties (4.0.1)
    rake (0.9.6)
    rdoc (4.0.0)
    sprockets (2.10.1)
    sprockets-rails (2.0.1)
    test-unit (2.0.0.0)
    thor (0.18.1)
    thread_safe (0.1.3)
    tilt (1.4.1)
    treetop (1.4.15)
    tzinfo (0.3.38)
    
    Install the sqlite-ruby
    [root@centosAshley02 ~]# yum install sqlite-devel
    [root@centosAshley02 ~]# gem install sqlite3
    
    check the gem list again and find the sqlite
    [root@centosAshley02 ~]# gem list
    
    *** LOCAL GEMS ***
    
    actionmailer (4.0.1)
    actionpack (4.0.1)
    activemodel (4.0.1)
    activerecord (4.0.1)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.1)
    arel (4.0.1)
    atomic (1.1.14)
    bigdecimal (1.2.0)
    builder (3.1.4)
    bundler (1.3.5)
    erubis (2.7.0)
    hike (1.2.3)
    i18n (0.6.5)
    io-console (0.4.2)
    json (1.7.7)
    mail (2.5.4)
    mime-types (1.25.1)
    minitest (4.3.2)
    multi_json (1.8.2)
    polyglot (0.3.3)
    psych (2.0.0)
    rack (1.5.2)
    rack-test (0.6.2)
    rails (4.0.1)
    railties (4.0.1)
    rake (0.9.6)
    rdoc (4.0.0)
    sprockets (2.10.1)
    sprockets-rails (2.0.1)
    sqlite3 (1.3.8)
    sqlite3-ruby (1.3.3)
    test-unit (2.0.0.0)
    thor (0.18.1)
    thread_safe (0.1.3)
    tilt (1.4.1)
    treetop (1.4.15)
    tzinfo (0.3.38)
    
    Almost done, We have to install execjs for javascript runtime and rubyracer
    gem install debugger-ruby_core_source -v 1.2.2
    sources: http://guides.rubyonrails.org/getting_started.html
    https://gist.github.com/fabrizioc1/1083087
    http://sqlrelay.sourceforge.net/sqlrelay/gettingstarted/sqlite.html https://github.com/cldwalker/debugger/issues/12