I’ve read some complicated how-to docs online today about how to use Ruby on Rails with various web server implementations. I’ve read some on Mongrel and FastCGI, and realize that for me at this point I just want to stick some Ruby code in a web page and experiment. I’ve already installed Ruby on Rails on my MacBook, but on my Linux web server in the shop I just want to play around with something simple.
So I ran across this “eruby” which basically acts very similar to what I’ve experienced with some simple php stuff. Basically you just rename your file from a .html file to a .rhtml and insert some special tags that start with <% and end with a %> … Of course, on the webserver end there are a few things to do also. I used some of the info on this webpage to configure the httpd.conf after I had installed eruby. I’m using Fedora Core 5 so I just used yum install to pull down all the eruby and ruby packages I could find and installed them. Here is a snippet from the Ruby book that got me up and running:
In order to use eruby with the Apache Web server, you need to perform the following steps.
Copy the eruby binary to the cgi-bin directory.
Add the following two lines to httpd.conf:
AddType application/x-httpd-eruby .rhtml Action application/x-httpd-eruby /cgi-bin/eruby
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 directive 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 site-wide Ruby script as well.
DirectoryIndex index.html index.shtml /cgi-bin/index.rb
Hope this helps others trying to unravel Ruby.