Making questionable headway with erubis

I am using the example here:

http://www.kuwata-lab.com/erubis/users-guide.06.html

and I am almost working, with a failure as follows from the apache error
log:

[Thu Dec 29 14:07:36 2011] [error] (8)Exec format error: exec of
‘/home/xeno/public_html/ex.rhtml’ failed
[Thu Dec 29 14:07:36 2011] [error] [client 10.151.8.152] Premature end
of script headers: ex.rhtml
–snip–

The file is taken verbatum from the post. In fact for good measure, I
did it again, just to make sure I wasn’t forgetting something. Please
someone suggest something here.

Sorry. Perhaps I just need to be more specific. The section of the doc
I am trying is:

  6-11   Helper Class for mod_ruby

Thanks Andrew R Jackson, he developed ‘erubis-run.rb’ which enables you
to use Erubis with mod_ruby.

  1. Copy ‘erubis-2.7.0/contrib/erubis-run.rb’ to the ‘RUBYLIBDIR/apache’
    directory (for example ‘/usr/local/lib/ruby/1.8/apache’) which
    contains ‘ruby-run.rb’, ‘eruby-run.rb’, and so on.

    $ cd erubis-2.7.0/
    $ sudo copy contrib/erubis-run.rb /usr/local/lib/ruby/1.8/apache/

  2. Add the following example to your ‘httpd.conf’ (for example
    ‘/usr/local/apache2/conf/httpd.conf’)

    LoadModule ruby_module modules/mod_ruby.so

    RubyRequire apache/ruby-run
    RubyRequire apache/eruby-run
    RubyRequire apache/erubis-run
    <Location /erubis>
    SetHandler ruby-object
    RubyHandler Apache::ErubisRun.instance

    <Files *.rhtml>
    SetHandler ruby-object
    RubyHandler Apache::ErubisRun.instance

  3. Restart Apache web server.

    $ sudo /usr/local/apache2/bin/apachectl stop
    $ sudo /usr/local/apache2/bin/apachectl start

  4. Create *.rhtml file, for example:

    Now is<%= Time.now %> Erubis version is<%= Erubis::VERSION %>
  5. Change mode of your directory to be writable by web server process.

    $ cd /usr/local/apache2/htdocs/erubis
    $ sudo chgrp daemon .
    $ sudo chmod 775 .

  6. Access the *.rhtml file and you’ll get the web page.

You must set your directories to be writable by web server process,
because Apache::ErubisRun calls Erubis::Eruby.load_file() internally
which creates cache files in the same directory in which ‘*.rhtml’ file
exists.

It appears that one problem I have with this is there is NO eruby around
to install, and even the erubis example I am trying to use, uses eruby.
Is this whole realm of work just diseased? It’s a nightmare.

On 12/29/2011 02:16 PM, Xeno C. wro

Looks like I may need to merely find the old eruby gem…??

Xeno C. wrote in post #1038789:

Looks like I may need to merely find the old eruby gem…??

The trouble is, almost nobody runs Ruby this way any more, and so you’re
likely to find yourself without support even if you manage to make it
work. mod_ruby is crusty, and especially having multiple ruby apps all
sharing the same ruby interpreter instance is a recipe for security
nightmares and applications stomping on each other.

These days, I suggest you would be best running one of the following:

  • Phusion Passenger, a.k.a. mod_rails
  • A reverse proxy (e.g. Apache mod_proxy or Nginx) talking to a ruby
    backend webserver (e.g. mongrel, unicorn, rainbows etc)
  • fastcgi, if neither of the above can work in your situation

In each case, the idea is that each ruby app is a self-contained HTTP
server, with extra instances being forked as required to handle larger
load. Phusion and mod_fcgi can do this dynamically for you.

You need some sort of framework for your app, unless you want to write
native Rack apps. I would suggest Sinatra as a very simple approach
which supports ERB templates nicely.

Regards,

Brian.