From: "Ara.T.Howard" Date: 2003-12-19T01:56:58+09:00 Subject: Re: Ruby as CGI with Apache on Linux On Thu, 18 Dec 2003, Zach Dennis wrote: > I feel bad for asking this question, but I am going to pull my hair out with > this. I recently got Ruby to run as a cgi under Apache2/Win2k combination. > Works great. I am now trying to do the same thing on Apache2/Redhat9 combo, > but to no avail. I keep getting the Server Error 500, premature end of > script headers. > > Here is my Apache config: > ------------------------------ > > ServerAdmin root@localhost > DocumentRoot "/var/www/html" > > Options Indexes FollowSymLinks > AllowOverride None > Order allow,deny > Allow from all > > > Order allow,deny > Deny from all > > > AllowOverride None > Order allow,deny > Allow from all > > ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" > AddType application/x-httpd-ruby .rb > Action application/x-httpd-ruby /usr/local/bin/ruby > i'm sure about this virtual/app-handler type set up, but it seems like you may need an ExecCGI in there somewhere... > Here is my Script that I am trying to run( test.rb ): > ----------------------------------------------------- > #!/usr/local/bin/ruby > print "Content-type: text/html\r\n" > print "Hello" this does not work, you must have _two_ \r\n terminators #!/usr/local/bin/ruby print "Content-type: text/html\r\n\r\n" print "Hello" better still (since you never need remember this): #!/usr/local/bin/ruby require 'cgi' CGI.new.out { "Hello" } > I was having this problem on my windows box at first but then I changed the > first line to read: > #! ruby > and it has worked ever since. However I have changed the first line on my > test.rb file on the Linux box to the following variations: > #! ruby > #!/usr/local/bin/ruby > #!/bin/ruby > #!/bin/env ruby > #! /bin/env ruby > and to not avail does it work. All files are owned by root. Any ideas? ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ all files should not owned by root. they should be owned, readable, and executable by, the web user. this is probably user nobody, httpd, or apache depending on your distro/config. do ps -elf | egrep 'httpd' to find out HTH. -a -- ATTN: please update your address books with address below! =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | STP :: http://www.ngdc.noaa.gov/stp/ | NGDC :: http://www.ngdc.noaa.gov/ | NESDIS :: http://www.nesdis.noaa.gov/ | NOAA :: http://www.noaa.gov/ | US DOC :: http://www.commerce.gov/ | | The difference between art and science is that science is what we | understand well enough to explain to a computer. | Art is everything else. | -- Donald Knuth, "Discover" | | /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done' ===============================================================================