Create  Edit  Diff  FrontPage  Index  Search  Changes  Login

InstallingOnMacOSX

Note

This assumes you have installed the Ruby 1.8 installer package at <URL:http://homepage.mac.com/discord/Ruby>, or compiled the latest stable Ruby and installed in /usr/local.

The above link is broken.

Install modruby

Compile and install modruby as described in the InstallGuide.

Configure modruby

Create a new directory: /etc/httpd/additions

Create a text file (with unix line endings) at /etc/httpd/additions/modruby.conf; with these contents:

LoadModule ruby_module /libexec/apache2/mod_ruby.so

<IfModule mod_ruby.c>
  RubyRequire apache/ruby-run

  # Excute files under /ruby as Ruby scripts
  <Directory /Library/WebServer/Documents/ruby>
    Options ExecCGI
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Directory>

  # Execute *.rbx files as Ruby scripts
  <Files *.rbx>
    Options ExecCGI
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>
</IfModule>

Now, add this line to the end of your httpd.conf (/etc/httpd/httpd.conf):

Include /private/etc/httpd/additions/*.conf

modruby is now installed and configured. Run 'sudo apachectl graceful' to reload the configuration.

Test the Configuration

In /Library/WebServer/Documents, create a folder named "ruby".

Create a file named "test" in that folder, with these contents:

require 'cgi'
cgi = CGI.new('html4')
cgi.out{
  cgi.html{
    cgi.head{ cgi.title{"number picker"} } +
    cgi.body{
      cgi.h1{Time.now.to_s} +
      cgi.p{"I choose number #{rand(100)}"}
    }
  }
}

Make it executable ('chmod a+x filename' in the terminal).

Visit http://localhost/ruby/test

Now, copy the file to the WebServer/Documents folder (ruby's parent folder) and rename it to "test.rbx".

Visit http://localhost/test.rbx

Last modified:2010/01/07 23:20:28
Keyword(s):
References:[InstallGuide]