Problems getting Apache 2.0.43 and erb to work


(Jon A. Lambert) #1

I’m running Apache 2.0.43 on Windows XP and trying to setup erb (eruby?).

I receive the following in the apache error.log
[error] [client 10.0.0.2] Premature end of script headers: erb

My http.conf configuration contains:
AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/erb

I do not have mod_ruby nor mod_cgi installed. I can however execute
Perl and Ruby scripts in the cgi-bin directory.

I’m using the test eruby web page from the The Pragmatic Programmers help file:

eruby example

Enumeration

    <%(1..10).each do|i|%>
  • number <%=i%>
  • <%end%>

Environment variables

<%ENV.keys.sort.each do |key|%> <%end%>
<%=key%> <%=ENV[key]%>

Interestingly enough in running the a ruby script copied from the same help file
I was getting this error:
malformed header from script. Bad header=HTTP/1.0 200 OK: rubytest.rb
until I commented out the print statement that produces the header.
#!c:\apps\ruby\bin\ruby

···

#print "HTTP/1.0 200 OK\r\n"
print "Content-type: text/html\r\n\r\n"
print “Hello World!\r\n”

So I tried a number of similar variations for the erb/rhmtl page with no success.

What am doing wrong here?

Thanks


(Jon A. Lambert) #2

“Jon A. Lambert” wrote:

I’m running Apache 2.0.43 on Windows XP and trying to setup erb (eruby?).

I receive the following in the apache error.log
[error] [client 10.0.0.2] Premature end of script headers: erb

My http.conf configuration contains:
AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/erb

FWIW, In case others are having this problem, I finally got erb to work.

I had to make the following modifications to the erb starting script:
115: # src = $<.read
116: src = File.new(ENV[‘PATH_TRANSLATED’]).read # $< is nil
117: exit 2 unless src
118: print “Content-type: text/html\r\n\r\n” # Malformed header unless content-type given

···


J. Lambert