[Long] Re: CGIs with OSX - progress report, premature end of script headers
[Long] Re: CGIs with OSX - progress report, premature end of script headers
- Subject: [Long] Re: CGIs with OSX - progress report, premature end of script headers
- From: email@hidden
- Date: Mon, 26 Mar 2001 13:16:51 EST
I don't think we're in Kansas anymore.
This discussion will be incomprehensible to total Unix newbies and laughable
to gurus; bear with me.
OK, I figured out how to get to root. It seems there are several ways. I'm
using a technique found at www.macosx.com
sudo /bin/tcsh
It's Greek to me, but it works.
Now here's what I have discovered about CGIs
1) You have to edit the httpd.conf file found at
HD/private/etc/httpd/httpd.conf
(I will use "/" when accessing via Telnet or Fetch, and ":" when accessing
via MacOS.)
This directory is invisible in the GUI, but visible by Telnet and Fetch. I
wanted to make a backup copy of that file first, so I downloaded a copy with
Fetch, then renamed the original to httpd.conf (orig) by using
mv httpd.conf http.conf (orig)
with the working directory being private/etc/httpd (I'm using a lot of cd and
pwd to keep my bearings). Somewhere in there I figured out I needed to give
myself permission to modify the file and its directory (since I was not
connected via FTP as root). That would be
chmod 660 httpd
when the working directory is private/etc, to change the directory
permissions, and
chmod 660 httpd.conf
when the working directory is private/etc/httpd, to change the file
permissions (yes I know I can type the full path without switching
directories, bear with me).
2) The httpd.conf file. It's a long read and there is probably no substitute
for going thru the whole thing, but here are the relevant lines:
<Directory "/Library/WebServer/Documents">
Options +Indexes +FollowSymLinks +ExecCGI +MultiViews
The pertinent part above is "ExecCGI". Commands need to be followed by a
blank line (actually crlfcrlf AKA /r/n/r/n). Actually, I think only the last
command in a set, before a comment, needs that ending. Also, the Apache docs
online indicate the "+" is needed, the httpd.conf file with OSX doesn't.
Then you must indicate what extensions are to be recognized as CGI scripts. I
added/modified these lines
AddHandler cgi-script .cgi
AddHandler cgi-script .acgi
AddHandler cgi-script cgi
AddHandler cgi-script acgi
I don't know if the "." makes a difference, I'm just trying all
possibilities. Note also the line
ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"
ScriptAlias tells the server that everything in the referenced directory is
an executable. I did not explore further (I wanted the CGI in the same
directory as the calling document, for now).
Then, save the new httpd.conf file to private/etc/httpd/httpd.conf and
restart Apache (in the Sharing control panel in OSX) (how to quit and restart
via Telnet? Must be doable, help please).
Finally, I get this response when I try to run my CGI:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, [no address given] 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.
This is progress! Apache is seeing the CGI and trying to execute it. So I
look into the server error log, located at
var/log/httpd/error_log
and do
cat error_log
The relevant error line is
[Mon Mar 26 11:16:31 2001] [error] [client 192.168.101.14] Premature end of
script headers: /Library/WebServer/Documents/spitback2.acgi
This is where I am stumped. The header lines in my script are (watch line
wrap)
property crlf : (ASCII character 13) & (ASCII character 10)
property http_10_header : "HTTP/1.0 200 OK" & crlf & "Server: Apache" &
crlf & "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf
... obviously adapted from Chuck Shotton's work. I have the obligatory "&
crlf & crlf", so I do not understand why Apache reports "Premature end of
script headers:". Any ideas?
Jeff Baumann
email@hidden
www.linkedresources.com