The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, [email protected] and inform them
of the time the error occurred, and anything you might have done that
may have caused the error.
More information about this error may be available in the server error
log."
Error log says:
[Wed Jan 26 13:21:53 2011] [error] [client ::1] (8)Exec format error:
exec of ‘Dir/cgi-bin/test.rhtml’ failed
[Wed Jan 26 13:21:53 2011] [error] [client ::1] Premature end of script
headers: test.rhtml
I have copied “eruby” executable to “Dir/cgi-bin/” directory and
configured apache (2.2) as follows:
of the time the error occurred, and anything you might have done that
headers: test.rhtml
Your .rhtml files shouldn’t be in cgi-bin/, they should be in
public_html/ or similar. Looks like Apache’s trying to execute the
.rhtml file, which isn’t an executable.
of the time the error occurred, and anything you might have done that
headers: test.rhtml
Your .rhtml files shouldn’t be in cgi-bin/, they should be in
public_html/ or similar. Looks like Apache’s trying to execute the
.rhtml file, which isn’t an executable.
-Justin
Thanks Justin for your comments!
I tried keeping .rhtml file in htdocs directory (DocumentRoot directory)
and I double checked the permission:
-rwxr-xr-x test.rhtml*
But I am still getting the same error. Any ideas? Thanks!
One problem is that you must not output a blank line before the HTTP
headers. That will give the Apache error you saw, at least it does with
CGI scripts. (Having said that, I’m not 100% sure that rhtml files
should generate HTTP headers in the first place)
A second problem is that I don’t think you should use ‘print’ inside
rhtml. Use <%= … %> instead.
Have you installed a copy of eruby inside your cgi-bin directory in that
location? Is it executable?
To be honest, I think you’ll find almost nobody uses ruby this way any
more, because it gives you the worst of all worlds: the inefficiency of
cgi-bin (forking a new ruby interpreter for every request) with the
PHP-like muddle of mixing your application logic inside your HTML
templates.
You should probably look at writing an application using a simple
framework like Sinatra, which is just a layer on top of Rack. For
development you can run it as a standalone webserver on its own port.
For production you can either run it inside Apache using Phusion
Passenger, or you can run a pool of mongrel/thin/unicorn/rainbows!
webservers and proxy to them.