mod_ruby & Apache

Discussion in 'Ruby' started by Dr. Ephemeron, Mar 4, 2004.

  1. 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>
    Dr. Ephemeron, Mar 4, 2004
    #1
    1. Advertising

  2. 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 ...
    ><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
    Paul Vudmaska, Mar 4, 2004
    #2
    1. Advertising

  3. "Paul Vudmaska" <> wrote in message
    news:...
    > 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!
    Dr. Ephemeron, Mar 4, 2004
    #3
  4. Dr. Ephemeron

    Kent Dahl Guest

    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[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___)
    Kent Dahl, Mar 4, 2004
    #4
  5. 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" <> wrote in message
    news:c27k07$kcg$...
    > 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[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___)
    >
    Dr. Ephemeron, Mar 4, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Heinemeier Hansson

    Memory consumption of Ruby/mod_ruby combo on Apache

    David Heinemeier Hansson, Sep 9, 2003, in forum: Ruby
    Replies:
    3
    Views:
    94
    Fritz Heinrichmeyer
    Sep 10, 2003
  2. David Heinemeier Hansson
    Replies:
    0
    Views:
    98
    David Heinemeier Hansson
    Feb 13, 2004
  3. Robert McKinnon
    Replies:
    1
    Views:
    160
    Dave Thomas
    Mar 6, 2004
  4. George Moschovitis

    mod_ruby and Apache ForceType

    George Moschovitis, Jun 22, 2004, in forum: Ruby
    Replies:
    2
    Views:
    152
    Dick Davies
    Jun 23, 2004
  5. Victor Reyes
    Replies:
    5
    Views:
    107
    Victor Reyes
    Sep 15, 2004
Loading...

Share This Page