Chapter 2. Library Installation

The simplest way to install ruby-web is to install the gem:

% gem install ruby-web
     

Then, you can use ruby-web in your cgi programs:

#!/usr/bin/env ruby

require 'rubygems'
require_gem 'ruby-web'

Web::open do
  puts "Hello World"
end
			

Another way to install ruby-web as a library is to use the tar.gz distribution

% tar -xvzf ruby-web_x.x.x.tar.gz
% cd ruby-web_x.x.x
% ruby install.rb config
% ruby install.rb setup
% ruby install.rb install
       

Similar to above, you can now use ruby-web in your cgi programs:

#!/usr/bin/env ruby

require 'web'

Web::open do
  puts "Hello World"
end

Note: for compatibility with cgi.rb:

require "web/shim/cgi"

Note: this this does compile and install the ruby-web interpreter, but you are free to ignore it.

Note: these examples are compatible with FastCGI and mod_ruby. Configure your webserver, and in the case of fastcgi, install the fastcgi ruby libraries. Ruby-web will detect the server environment and run appropriately.