Mod_ruby & Apache

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

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

Dr. Ephemeron wrote:

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

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

Dr. Ephemeron wrote:

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-like is:

RubyRequire apache/ruby-debug RubyTimeOut 60 #Execute files under /ruby as Ruby scripts SetHandler ruby-object RubyHandler Apache::RubyDebug.instance RubySafeLevel 2 Options ExecCGI

…but this is on Apache 1.3.29.

···


([ Kent Dahl ]/)_ ~ [ Kent Dahl - Kent Dahl ]/~
))_student_/(( _d L b_/ Master of Science in Technology )
( __õ|õ// ) ) Industrial economics and technology management (
_
/ö____/ (_engineering.discipline=Computer::Technology)

I have a similar difficulty trying to run rublog with mod_ruby on
Apache.

Apache is not using the Content-type field from the rublog output,
instead it adds its own with type text/plain. So the web browser thinks
it is receiving plain text. I used a proxy server to see the HTTP
Response, it looks like:
HTTP/1.1 200 OK
Server: Apache/2.0.48 (Fedora)
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain; charset=UTF-8

1c3b

Content-type: text/html
Last-modified: Thu, 01 Jan 1970 00:00:00 GMT

<?xml version="1.0" encoding="utf-8"?> ...

My setup:
ruby 1.8.1 (2004-02-28)
httpd 2.0.48-1.2
mod_ruby 1.1.2
rublog lastest CVS version[1]

My httpd.conf:

RubyRequire apache/ruby-run

<Files *.rbx>
  SetHandler ruby-object
  RubyHandler Apache::RubyRun.instance
  RubyAddPath /home/aaa/apps/rublog/rublog
  Options ExecCGI
</Files>

Alias /blog “/home/aaa/docs/blog/cgi/rublog.rbx”

For now I’ll go back to running rublog as a cgi script.

Regards,
Rob

[1] To prevent a security error when running rublog I had to change
line 168 of FileEntries.rb from:
Dir.glob(File.join(entry_dir.full_name, “")).each do |filename|
to:
file_pattern = File.join(entry_dir.full_name, "
”)
file_pattern.untaint
Dir.glob(file_pattern).each do |filename|

···

Date: Sat, 06 Mar 2004 05:56:14 GMT

— “Dr. Ephemeron” me@privacy.net wrote:

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

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


Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster

“Paul Vudmaska” paul@vudmaska.com wrote in message
news:404698B5.1000403@vudmaska.com

Dr. Ephemeron wrote:

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!

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 “”
print “

eRuby Test!



” 1.upto(10) do |x|
print " Hello Ruby!
\n"
end
print "


\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

ScriptAlias /ruby/ /var/www/ruby/

<Directory /var/www/ruby>
AllowOverride All
Options ExecCGI

Order allow,deny
Allow from all

RubyRequire apache/ruby-run SetHandler ruby-object RubyHandler Apache::RubyRun.instance #Options ExecCGI #This is not needed since it is in the Directory directive above. RubyRequire apache/eruby-run SetHandler ruby-object RubyHandler Apache::ERubyRun.instance

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” kentda+news@stud.ntnu.no wrote in message
news:c27k07$kcg$1@tyfon.itea.ntnu.no…

Dr. Ephemeron wrote:

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-like is:

RubyRequire apache/ruby-debug RubyTimeOut 60 #Execute files under /ruby as Ruby scripts SetHandler ruby-object RubyHandler Apache::RubyDebug.instance RubySafeLevel 2 Options ExecCGI

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

If you come up with a solution for this, please send me a patch and
I’ll integrate it in.

Cheers

Dave

···

On Mar 6, 2004, at 0:16, Robert McKinnon wrote:

Apache is not using the Content-type field from the rublog output,
instead it adds its own with type text/plain. So the web browser thinks
it is receiving plain text. I used a proxy server to see the HTTP

Yep, that is exactly what is happeing to me.

I just used the mod_ruby Apache module.

These lines at the top of an *.rbx file work for me:

r = Apache.request
r.content_type = “text/html”
r.send_http.header

···

Optionally, you could also add “rbx” to your “apache-mime.types” file like
this:

text/html html htm rbx


Your could use “mod_mime_magic” and it will most likely detect it as
text/html.


You can change the DefaultType in httpd2.conf like this:

DefaultType = text/html

This is probably the least desirable.


Later,

Dr. Ephemeron

“Robert McKinnon” rob_m_mckinnon@yahoo.com wrote in message
news:20040306061654.25970.qmail@web13503.mail.yahoo.com

I have a similar difficulty trying to run rublog with mod_ruby on
Apache.

Apache is not using the Content-type field from the rublog output,
instead it adds its own with type text/plain. So the web browser thinks
it is receiving plain text. I used a proxy server to see the HTTP
Response, it looks like:
HTTP/1.1 200 OK
Date: Sat, 06 Mar 2004 05:56:14 GMT
Server: Apache/2.0.48 (Fedora)
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain; charset=UTF-8

1c3b

Content-type: text/html
Last-modified: Thu, 01 Jan 1970 00:00:00 GMT

<?xml version="1.0" encoding="utf-8"?> ...

My setup:
ruby 1.8.1 (2004-02-28)
httpd 2.0.48-1.2
mod_ruby 1.1.2
rublog lastest CVS version[1]

My httpd.conf:

RubyRequire apache/ruby-run

<Files *.rbx>
  SetHandler ruby-object
  RubyHandler Apache::RubyRun.instance
  RubyAddPath /home/aaa/apps/rublog/rublog
  Options ExecCGI
</Files>

Alias /blog “/home/aaa/docs/blog/cgi/rublog.rbx”

For now I’ll go back to running rublog as a cgi script.

Regards,
Rob

[1] To prevent a security error when running rublog I had to change
line 168 of FileEntries.rb from:
Dir.glob(File.join(entry_dir.full_name, “")).each do |filename|
to:
file_pattern = File.join(entry_dir.full_name, "
”)
file_pattern.untaint
Dir.glob(file_pattern).each do |filename|

— “Dr. Ephemeron” me@privacy.net wrote:

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

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


Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

require “cgi”
cgi = CGI.new()
print cgi.header(“content”=>“text/html”)

Dr. Ephemeron

“Robert McKinnon” rob_m_mckinnon@yahoo.com wrote in message
news:20040306061654.25970.qmail@web13503.mail.yahoo.com

···

I have a similar difficulty trying to run rublog with mod_ruby on
Apache.

Apache is not using the Content-type field from the rublog output,
instead it adds its own with type text/plain. So the web browser thinks
it is receiving plain text. I used a proxy server to see the HTTP
Response, it looks like:
HTTP/1.1 200 OK
Date: Sat, 06 Mar 2004 05:56:14 GMT
Server: Apache/2.0.48 (Fedora)
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain; charset=UTF-8

1c3b

Content-type: text/html
Last-modified: Thu, 01 Jan 1970 00:00:00 GMT

<?xml version="1.0" encoding="utf-8"?> ...

My setup:
ruby 1.8.1 (2004-02-28)
httpd 2.0.48-1.2
mod_ruby 1.1.2
rublog lastest CVS version[1]

My httpd.conf:

RubyRequire apache/ruby-run

<Files *.rbx>
  SetHandler ruby-object
  RubyHandler Apache::RubyRun.instance
  RubyAddPath /home/aaa/apps/rublog/rublog
  Options ExecCGI
</Files>

Alias /blog “/home/aaa/docs/blog/cgi/rublog.rbx”

For now I’ll go back to running rublog as a cgi script.

Regards,
Rob

[1] To prevent a security error when running rublog I had to change
line 168 of FileEntries.rb from:
Dir.glob(File.join(entry_dir.full_name, “")).each do |filename|
to:
file_pattern = File.join(entry_dir.full_name, "
”)
file_pattern.untaint
Dir.glob(file_pattern).each do |filename|

— “Dr. Ephemeron” me@privacy.net wrote:

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

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


Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com