|By Seema Alevoor and Marina Sum, January 30, 2007, updated: February 27, 2008|
Ruby on Rails (henceforth, RoR) is an open-source project in the Ruby interpreted scripting language with the goal of delivering a framework for efficiently developing Web applications. Sun Java System Web Server 7.0 (henceforth, Web Server 7.0), the latest Web server release from Sun, bundles FastCGI, an extension to the Common Gateway Interface (CGI), for scripting environments such as RoR. In addition, Web Server 7.0 offers many robust capabilities, including support for the Solaris 64-bit platform and cluster management as well as integration with Sun IDEs.
This article first describes how to install the Ruby language; RubyGems, the project for the standard that creates and manages libraries; Ruby on Rails; and the FastCGI Ruby gem. A gem is a packaged Ruby application or library. Later in the article, you learn how to create an RoR application and configure Web Server 7.0 to run RoR.
Note the following:
|-||Installing Ruby, RubyGems, and Rails|
|-||Creating a HelloWorld RoR Application|
|-||Configuring Web Server 7.0|
The installations for Ruby, Ruby Gems, and Rails copy the executables to the
/usr/local/bin directory. For easy execution, add that path to your
Note: If you cannot write to the
/usr/local/bin directory, become root before starting the installation process.
To install Ruby:
% cd /ruby/ruby-1.8.4
% make install
gccbut encounter compile-time errors, delete the
gccdirectory from your
PATHvariable and switch to one of the Sun Studio compilers.
To install RubyGems:
% cd /ruby/rubygems-0.9.0
% export DLN_LIBRARY_PATH=/ruby/ruby-1.8.4/.ext/sparc-solaris2.10
% export RUBYLIB=/ruby/ruby-1.8.4/ext:/ruby/ruby-1.8.4/lib:/ruby-1.8.4:/ruby/ruby-1.8.4/.ext/sparc-solaris2.10
% ruby setup.rb --rbconfig=/ruby/ruby-1.8.4/rbconfig.rb
To install Ruby on Rails:
% export http_proxy=http://proxy_hostname
% gem install rails --include-dependencies
Installing FastCGI Ruby Gem
FastCGI offers a more efficient way than CGI for Web servers to call applications. To install the FastCGI Ruby gem:
% cd /ruby
% gem install fcgi -- --with-fcgi-include=/fcgi-2.4.0/include --with-fcgi-lib=/fcgi-2.4.0/libfcgi/.libs
To create a Hello World application in RoR:
% mkdir /ruby/samples
% cd /ruby/samples
% rails hello-world
% cd hello-world
% ruby script/generate controller hello
app/views/hellodirectory with the following one-line content:
% ruby script/server
http://localhost:3000/helloon your browser.
Hello!, is displayed.
Next, add some substance to the application:
% cd /ruby/samples/hello-world/app/controllers
hello_controller.rbfile, add the following three boldfaced lines.
class HelloController < ApplicationController def sayhello render_text "Hello! This is a simple example." end end
% ruby script/server
Hello! This is a simple application.
To configure Web Server 7.0:
magnus.conffile to load the FastCGI plug-in that is bundled with Web Server 7.0:
Init fn="load-modules" shlib="libfastcgi.so" shlib_flags="(global|now)"
/bin/wadm pull-config --user=admin --config=CONFIG hostname
localhostand 80 are the host name and port number of Web Server 7.0, respectively.
Hello! This is a simple example.
Configuring Web Server 7.0 to run RoR with FastCGI is simple and hassle-free. A future article will describe how to run JRuby on Web Server 7.0. Stay tuned!