I am trying to get Erubis setup to process .rhtml files on an Apache web server.
I have Ruby installed (v 1.9.2p290) and I installed Erubis(2.7.0) through Ruby Gems.
I can't seem to find the proper way to configure the httpd.conf file -- I found a guide for setting up eruby on Apache at http://www.ruby-doc.org/docs/ProgrammingRuby/html/web.html -- I tried using those config settings, restarted apache, etc... but the rhtml file is not being parsed (it's just outputting the ruby expression as flat text)
I added the following lines to the httpd.conf file, but it didn't do anything--
AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby
I feel like that would work if I was installing eruby itself, not erubis. The erubis website doesn't offer any clear examples on how to get this up and running, other than installing via gems which I've already done.
I also tried changing the file and conf setting from .rhtml to .eruby, just in case, and that wasn't working either.
Please help!
Apparently this style of using embedded Ruby is no longer the way to go, but I wanted to run eruby as well & found one way to get erubis to handle .rhtml pages by adding a CGI shell script to pass the requested page to erubis. My solution is described here:
http://techdog.tumblr.com/post/36496065877/configure-erubis-cgi-in-apache
I have Apache/2.2.22 on Ubuntu 12.04 & Ruby 1.8.7. I installed the erubis 2.7.0 implementation & copied the executable erubis file to Apache’s cgi folder, in my case to /usr/lib/cgi-bin/erubis.
I configured a cgi script called erubis.sh to handle requests for .rhtml files by adding these directives to /etc/apache/httpd.conf:
AddType application/x-httpd-eruby .rhtml
Application application/x-httpd-eruby /cgi-bin/erubis.sh
I made sure that the Action module is enabled by running this command:
$ sudo a2enmod action
I created this bash shell script erubis.sh to handle requests for pages with embedded ruby:
#!/bin/bash
echo "Content-type: text/html"
echo
echo "<!DOCTYPE HTML>"
erubis -E Stdout <$DOCUMENT_ROOT$REQUEST_URI
It outputs a minimal http header then asks erubis to process the requested .rhtml file containing embedded Ruby. The Stdout enhancement option seemed necessary to get the output of the embedded Ruby blocks in the right places.