With Apache 1.3.28 it mostly works. Here is the test script I am running:
// It works without the following 2 lines, although instructions say it
needs them.
print "HTTP/1.1 200 OK\r\n"
print "Content-type: text/html\r\n\r\n"
print "<!DOCTYPE HTML PUBLIC '-//W3C/DTD HTML 4.01 Transitional//EN'>"
print "<html>
<head>
<title>eRuby Test!</title>
<meta http-equiv='Content-Type' content='text/html;
charset=iso-8859-1'>
</head>
<body>
<h1>" 1.upto(10) do |x|
print " Hello Ruby!<br>\n"
end
print " </h1></body>
</html>\n"
If I try this at the start of the script, I get errors:
print "HTTP/1.1 200 OK\r\n" #With or without this line is the same
error.
require 'cgi'
cgi = CGI.new
print cgi.header['type'=>'text/html']
Here is the error from the error_log:
Thu Mar 4 13:16:47 2004] [error] mod_ruby: error in ruby
/var/www/ruby/rubytest.rbx:6:in `[]': cannot convert Hash into Integer
(TypeError)
from /var/www/ruby/rubytest.rbx:6
from /usr/lib/ruby/1.8/apache/ruby-run.rb:70:in `load'
from /usr/lib/ruby/1.8/apache/ruby-run.rb:70:in `handler'
Here is what I added to httpd.conf to get it to work as well as it does with
Apache v1.3:
LoadModule ruby_module modules/mod_ruby.so
# After ClearModuleList
AddModule mod_ruby.c
<IfModule mod_alias.c>
ScriptAlias /ruby/ /var/www/ruby/
</IfModule>
<Directory /var/www/ruby>
AllowOverride All
Options ExecCGI
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
<IfModule mod_ruby.c>
RubyRequire apache/ruby-run
<Location /ruby/*.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
#Options ExecCGI #This is not needed since it is in the Directory
directive above.
</Location>
RubyRequire apache/eruby-run
<Location /*.rhtml>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Location>
</IfModule>
With Apache 2.0.47 it just loads it as a text file. In httpd.conf, I have
all the same stuff above except for:
AddModule mod_ruby.c #Not in httpd.conf for Apache2
eruby works fine on the web server root directory for both versions of
Apache.
Kent Dahl said:
Dr. Ephemeron said:
mod_ruby is reported installed by Apache and I can make a test *.rhtml file
in my html directory and it works fine.
When put a *.rbx file in my cgi-bin directory and browse it with Mozilla
1.4, it prints, but it prints everything in the file like this:
HTTP/1.1 200 OK
Content-type: text/html
<!DOCTYPE HTML PUBLIC ...
How does the relevant sections of your httpd.conf file look?
Do you have a "<Files *.rbx>" section that tells Apache to feed .rbx
files in the cgi directory to mod_ruby?
The config for one of my setups, where I use a separate directory for
all things .rb[x]-like is:
<IfModule mod_ruby.c>
RubyRequire apache/ruby-debug
RubyTimeOut 60
#Execute files under /ruby as Ruby scripts
<Location /ruby>
SetHandler ruby-object
RubyHandler Apache::RubyDebug.instance
RubySafeLevel 2
Options ExecCGI
</Location>
</IfModule>
...but this is on Apache 1.3.29.
--
(\[ Kent Dahl ]/)_ _~_ _____[
http://www.pvv.org/~kentda/ ]_____/~
))\_student_/(( \__d L b__/ Master of Science in Technology )
( \__\_õ|õ_/__/ ) _) Industrial economics and technology management (
\____/_ö_\____/ (____engineering.discipline_=_Computer::Technology___)