Wednesday, November 14, 2007

Building Ruby From Source On Nexenta

Currently Nexenta's package manager provides installations of Ruby 1.8.2 (the ruby package) and Ruby 1.8.4 (the ruby1.8 package). If you would like to build the latest version (1.8.6 as of this writing), these are instructions for the steps that I took beyond what is currently posted on the rubyonrails website. Keep in mind that your custom installation will not be available for update with the Synaptic package manager and may cause conflicts if you choose to install the version from the Nexenta repository, so you might want to consider overriding the default installation directory (in the directions, I specify --prefix=/usr/opt in the ruby_zone, but for the global zone, I tend to use $HOME as my installation path for non-Synaptic installations).

Install a Ruby on Rails Zone

Install a new zone called ruby_zone and login.

Build and Install Ruby From Source

  • root@ruby_zone:~# mkdir /usr/opt/sources
  • root@ruby_zone:~# cd /usr/opt/sources/
  • root@ruby_zone:/usr/opt/sources# wget http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz
  • root@ruby_zone:/usr/opt/sources# gunzip ruby-1.8.6.tar.gz
  • root@ruby_zone:/usr/opt/sources# tar -xf ruby-1.8.6.tar
  • root@ruby_zone:/usr/opt/sources# cd ruby-1.8.6
  • root@ruby_zone:/usr/opt/sources/ruby-1.8.6# apt-get install make gcc
  • root@ruby_zone:/usr/opt/sources/ruby-1.8.6# apt-get install zlib1g-dev (or else you will see an error that looks like remote_fetcher.rb:4:in `require': no such file to load -- zlib (LoadError) error when installing ruby gems)
  • root@ruby_zone:/usr/opt/sources/ruby-1.8.6# ./configure --prefix=/usr/opt --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
  • root@ruby_zone:/usr/opt/sources/ruby-1.8.6# make
  • root@ruby_zone:/usr/opt/sources/ruby-1.8.6# make test (expect to see a test succeeded message)
  • root@ruby_zone:/usr/opt/sources/ruby-1.8.6# make install

Setup Ruby Gems

  • root@ruby_zone:/usr/opt/sources/ruby-1.8.6# cd ..
  • root@ruby_zone:/usr/opt/sources# wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
  • root@ruby_zone:/usr/opt/sources# gunzip rubygems-0.9.4.tgz
  • root@ruby_zone:/usr/opt/sources# tar -xf rubygems-0.9.4.tar
  • root@ruby_zone:/usr/opt/sources# cd rubygems-0.9.4
  • root@ruby_zone:/usr/opt/sources/rubygems-0.9.4# /usr/opt/bin/ruby setup.rb
  • root@ruby_zone:/usr/opt/sources/rubygems-0.9.4# /usr/opt/bin/gem update (or else you may see Could not find rails (> 0) in any repository)

Install the Rails Gem

  • root@ruby_zone:/usr/opt/sources/rubygems-0.9.4# /usr/opt/bin/gem install rails --include-dependencies
  • root@ruby_zone:/usr/opt/sources/rubygems-0.9.4# mkdir /tmp/test_rails
  • root@ruby_zone:/usr/opt/sources/rubygems-0.9.4# /usr/opt/bin/rails /tmp/test_rails
  • root@ruby_zone:/usr/opt/sources/rubygems-0.9.4# cd /tmp/test_rails
  • root@ruby_zone:/tmp/test_rails# /usr/opt/bin/ruby script/server (expect WEBrick to start)

From a browser, open http://ipaddress.of.ruby_zone:3000 (I chose 192.168.0.115 as the ipaddress)

You should now see the Rails "Welcome aboard" screen!

No comments: