mod_ruby & Apache

D

Dr. Ephemeron

Sorry, if this seems like a simple problem, but I have:

Mandrake 9.2
Apache 2.0.47
mod_ruby 1.0.7
eruby 1.0.5

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 ...
<html>
<head>
 
P

Paul Vudmaska

Dr. Ephemeron said:
Sorry, if this seems like a simple problem, but I have:

Mandrake 9.2
Apache 2.0.47
mod_ruby 1.0.7
eruby 1.0.5

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 ...
<html>
<head>
.
.
.

It looks to me like it is probably an Apache setting that needs to be
changed, but I can't figure out which one. I am new to all of this and
struggling just to get it operational so I can learn more.

Thanks
That's possible but more likely, in my experience, you need to make the
rbx file executable.

Paul
 
D

Dr. Ephemeron

Paul Vudmaska said:
Dr. Ephemeron said:
Sorry, if this seems like a simple problem, but I have:
[snip]
That's possible but more likely, in my experience, you need to make
the
rbx file executable.

Paul

Well it's 755, so it is executable. And the print statements are working, so
it is executing... But it is not sending it as a HTML file, it's sending it
as a text file and the browser shows all the headers and tags in the print
statements. cgi.rb doesn't seem to work either when I include it.

Thanks!
 
K

Kent Dahl

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.
 
D

Dr. Ephemeron

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___)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top