Problems getting Apache 2.0.43 and erb to work

J

Jon A. Lambert

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:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>eruby example</title>
</head>
<body>
<h1>Enumeration</h1>
<ul>
<%(1..10).each do|i|%>
<li>number <%=i%></li>
<%end%>
</ul>
<h1>Environment variables</h1>
<table>
<%ENV.keys.sort.each do |key|%>
<tr>
<th><%=key%></th><td><%=ENV[key]%></td>
</tr>
<%end%>
</table>
</body>
</html>

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 "<html><body>Hello World!</body></html>\r\n"

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

What am doing wrong here?

Thanks
 
J

Jon A. Lambert

Jon A. Lambert said:
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
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top