Create  Edit  Diff  FrontPage  Index  Search  Changes  Login

InstallGuide

Install

Install mod_ruby like this:

$ tar zxvf mod_ruby-x.y.z.tar.gz
$ cd mod_ruby-x.y.z/
$ ./configure.rb --with-apxs=/usr/local/apache/bin/apxs
$ make
# make install

NB: If you can't find apxs on your system, install the apache development package (apache-dev on Ubuntu).

For Apache 1.3 change the configure script to point to:

$ ./configure.rb --with-apxs=/usr/bin/apxs

Configure Apache

Add these lines to httpd.conf.

LoadModule ruby_module /usr/local/apache/libexec/mod_ruby.so
## On Linux (FC3) this becomes
# LoadModule ruby_module /usr/lib/httpd/modules/mod_ruby.so  

# ClearModuleList
# AddModule mod_ruby.c

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

  # Excucute files under /ruby as Ruby scripts
  <Location /ruby>
  SetHandler ruby-object
  RubyHandler Apache::RubyRun.instance
  </Location>

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

For Apache 1.3, change:

LoadModule ruby_module /usr/local/apache/libexec/mod_ruby.so

to:

LoadModule ruby_module /usr/lib/apache/1.3/mod_ruby.so

On my Ubuntu system, running the Debian mod_ruby packages, version 1.2.4 with Apache2, the <Location> section above has one problem: if the request is sent to plain localhost/ruby or localhost/ruby/, mod_ruby crashes hard, and won't serve pages any longer. (The error is something like "/var/www/ruby/: Is a directory - /var/www/ruby/ (Errno::EISDIR)".) To fix it I use mod_rewrite to direct all requests to the bare directory to the index file in the directory:

RedirectMatch ^/(ruby|ruby/)$ /ruby/index.rb

Remember to add a <Directory> section

<Directory /var/www/ruby>
    Options ExecCGI
</Directory>

Or you'll get a 403 error.

Notes on InstallingOnMacOSX

Use eRuby with mod_ruby

Install eruby, and add these lines to httpd.conf.

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

  # Handle files under /eruby as eRuby files
  <Location /eruby>
  SetHandler ruby-object
  RubyHandler Apache::ERubyRun.instance
  </Location>

  # Handle *.rhtml files as eRuby files
  <Files *.rhtml>
  SetHandler ruby-object
  RubyHandler Apache::ERubyRun.instance
  </Files>
</IfModule>

<Directory /var/www/eruby>
    Options ExecCGI
</Directory>
Last modified:2005/08/03 00:35:59
Keyword(s):
References:[InstallingOnMacOSX] [FrontPage]