Friday, September 4, 2009

Installing eruby in Apache

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 the better performance. 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 can create Ruby-embedded files with an .rhtml suffix and configure the Web server to run the eruby executable on these documents to produces 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 cgi-bin directory
2.) Add the following two lines to httpd.conf.

AddType application/x-httpd-eruby .rhtml
Action application/x-http-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 directions that do not contain an index.html. For instance, the following directive would cause the embedded Ruby script index.rhtml to be searched for and served if neither index.html nor index.sthml existed in a directory.

DirectoryIndex.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:

Post a Comment