Tuesday, July 03, 2007

Installing eruby in Apache [programming ruby]

If you want to use erb-like page generation for a Web site that gets a reasonable amount
of traffic, you’ll probably want to switch across to using eruby, which has better per-
formance. You can then configure the Apache Web server to automatically parse Ruby-
embedded documents using eRuby, much in the same way that PHP does. You create
Ruby-embedded files with an .rhtml suffix and configure the Web server to run the
eruby executable on these documents to produce the desired HTML output.

To use eruby with the Apache Web server, you need to perform the following steps.
1. Copy the eruby binary to the cgi-bin directory.
2. Add the following two lines to httpd.conf.
AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby
3. If desired, you can also add or replace the DirectoryIndex directive such that
it includes index.rhtml. This lets you use Ruby to create directory listings for
directories that do not contain an index.html. For instance, the following direc-
tive would cause the embedded Ruby script index.rhtml to be searched for and
served if neither index.html nor index.shtml existed in a directory.
DirectoryIndex index.html index.shtml index.rhtml
Of course, you could also simply use a sitewide Ruby script as well.
DirectoryIndex index.html index.shtml /cgi-bin/index.rb

No comments :