Re-enabling mod_ruby on

I finally managed to re-enable mod_ruby on my server once again. This time around, I had a hard time enabling eRuby to work in Apache.

New Apache configuration file:

AddType text/html .rhtml
LoadModule ruby_module modules/
#<IfModule mod_ruby.c>
RubyRequire apache/ruby-run
RubyRequire apache/eruby-run
<Files *.rb>
Options +ExecCGI
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
<Files *.rhtml>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance

The Apache eRuby SetHandler (rhtml) was not able to render any html/ruby pages, while regular ruby scripts (.*rb) were able to run just fine.

Apache log error:
[Sun Aug 08 20:56:15 2010] [error] mod_ruby: (eval):45: (eval):45: uninitialized constant Apache::ERubyRun (NameError)


Specify the absolute path to the eRuby Apache module in /usr/lib/ruby/1.8/apache/eruby-run.rb.

Change  line 45

require ‘eruby’


require “/usr/lib/ruby/1.8/i386-linux/”

Restart Apache and eRuby should render html/ruby pages as expected.

I hope people find this useful (and save a headache) as I spent about 5 hours researching this problem and I wasn’t able to find this fix anywhere.

Leave a Reply

Your email address will not be published. Required fields are marked *