Cant get mod-ruby working on apache2

Apache is treating my script as a text file rather than running
it.Permission are correct, ruby and mod-ruby are both
installed (according to apache diagnostics).


##!/usr/bin/ruby
#print “HTTP/1.1 200 OK\r\n”
#print "Content-Type: text/plain\r\n\r\n"
puts ""
puts ""
puts "Test page"
puts ""
puts ""
puts "foobar"
puts ""
puts “”

My http.conf is the one specified by modruby.net:

"
[snip]

If the ruby module is installed, this will be enabled.

# for Apache::RubyRun RubyRequire apache/ruby-run

exec files under /ruby as ruby scripts.

<Location /cgi-bin>

SetHandler ruby-object

RubyHandler Apache::RubyRun.instance

Options ExecCGI

exec *.rbx as ruby scripts.

<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance

Options ExecCGI

"

If I run it as a straight cgi script it runs fine.

Apache is treating my script as a text file rather than running
it.Permission are correct, ruby and mod-ruby are both
installed (according to apache diagnostics).


##!/usr/bin/ruby
#print “HTTP/1.1 200 OK\r\n”
#print “Content-Type: text/plain\r\n\r\n”
puts “”
puts “”
puts “Test page”
puts “”
puts “”
puts “foobar”
puts “”
puts “”

My http.conf is the one specified by modruby.net:

"
[snip]

If the ruby module is installed, this will be enabled.

# for Apache::RubyRun RubyRequire apache/ruby-run

exec files under /ruby as ruby scripts.

<Location /cgi-bin>

SetHandler ruby-object

RubyHandler Apache::RubyRun.instance

Options ExecCGI

exec *.rbx as ruby scripts.

<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance

Options ExecCGI

^^^
Why is this uncommented?

···
"

If I run it as a straight cgi script it runs fine.


When you make your mark in the world, watch out for guys with erasers.
– The Wall Street Journal
Rasputin :: Jack of All Trades - Master of Nuns

exec *.rbx as ruby scripts.

<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance

Options ExecCGI

^^^
Why is this uncommented?

"

An experiment to see if adding it changed
anything - it didnt. So I
commented it out again.

exec *.rbx as ruby scripts.

<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance

Options ExecCGI

^^^
Why is this uncommented?

An experiment to see if adding it changed
anything - it didnt.

It should :slight_smile: Do you get any errors in the logs? Mod_ruby should
be loaded, or you’d get syntax errors using the RubyHandler directive.
Are the files executable by the user Apache runs as?

Here’s mine:

--------------8<-------------------------

LoadModule ruby_module lib/httpd/mod_ruby.so

If the ruby module is installed, this will be enabled.

# for Apache::RubyRun
RubyRequire apache/ruby-run
<FilesMatch "\.rbx$">
	Options +ExecCGI
	SetHandler ruby-object
	RubyHandler Apache::RubyRun.instance
</FilesMatch>


# handle *.rhtml as eruby files.
RubyRequire apache/eruby-run
<FilesMatch "\.rhtml$">
	SetHandler ruby-object
	RubyHandler Apache::ERubyRun.instance
</FilesMatch>

# debug
 RubyRequire auto-reload
--------------8<-------------------------

This is all in a single file called mod_ruby.conf. In the main
httpd.conf I just

Include /path/to/mod_ruby.conf

Round about Section 2 somewhere.

···


A physicist is an atom’s way of knowing about atoms.
– George Wald
Rasputin :: Jack of All Trades - Master of Nuns