According to the Apache error logs, I'm connecting okay, but something seems to
be off.i've been reading up on the config issues, and I've worked thru some of
them, but frankly I'm out of my element,
Yeah, MSWindows to *nix can be an exciting leap.
and concerned about munging up httpd.conf so badly I'll be sent away.
Backups. You do keep backups, right?
(One of these days I'm going to get version control running to my liking, and I'll keep everything under /etc in version control. For now, I just make a copy to work on and rename the old one *_nnn.bak or something, keeping track of the editing sequence in the _nnn portion.)
The script.. #!/usr/bin/perl -w print "Content-type: text/html\n\n"; print "<h2>Hello, World!</h2>\n";
...shows up in safari with the script text, but with "Hello World" in the header
font style!
Yeah, <h2> tends to do that.
As to why your browser is interpreting it as HTML when the Content-type declaration is too late, I couldn't say. Maybe the file name extension encouraged Apache to automatically put a Content-type of html into the stream ahead of the source?
!/usr/bin/perl -w print "Content-type: text/html\n\n"; print "
Hello, World! \n";
These are (AFAIK) the relevant httpd parts. Note that I was following a tutorial
on the O'reilly site, and one here <http://www.cgi101.com/learn/connect/mac.html>
and made the most progress with using my own home directory (as opposed to
/Lib/./CGI-Exe).
Fewer permissions issues there, yes. But that may not be a good thing, depending on whether or not you have that server facing the web.
(I'm not sure what makes the most sense, just for at-home development. I'd imagine the more real-world setup is better)
I've custom partitioned my hard drive. Most of my Unix apps (except for the default Apple installed ones) are installed on UFS partitions, and everything I have facing the web is on UFS, as well.
That meant that when one of the vulnerabilities about the Macintosh file types was published recently, I was ahead of the curve a bit.
In order to do that, I've had to be fairly careful with permissions and owners and such. Symbolic links to each user's web stuff placed in each user's home folder make it not too inconvenient to have the web stuff on its own partition.
I've set each user's web-facing directories and files to owned by user, but group is the apache user. The directories that serve the domain root are owned by the apache user. Directory permissions are read/write/search (rwx) for owner, read/search (r-x) for group, no permissions (---) for others.
<Directory /Users/mike/Sites> AllowOverride FileInfo AuthConfig Limit Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCGI DirectoryIndex index.html index.cgi <Limit GET POST OPTIONS PROPFIND> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS PROPFIND> Order deny,allow Deny from all </LimitExcept> </Directory>
This is in /etc/httpd/users , right?
and...
# To use CGI scripts: # #AddHandler cgi-script .cgi
# # To use server-parsed HTML files # #AddType text/html .shtml #AddHandler server-parsed .html
I personally am a bit of a bigot about file extensions. I don't use them except for perl because I don't have to, and because I prefer to have all my cgi in one place.
I put the cgi directory enabling directives in each users configuration in /etc/httpd/users :
ScriptAlias /~user/cgi/ "/Volumes/uw/users/user/cgi" <Directory "/Volumes/uw/users/user/cgi"> AllowOverride None Options None Order allow,deny Allow from all </Directory>
The log says this (which to my eyes looks better than what I've seen before
[Wed Mar 9 16:51:37 2005] [notice] Apache/1.3.33 (Darwin) PHP/4.3.2 configured -- resuming normal operations
[Wed Mar 9 16:51:37 2005] [notice] Accept mutex: flock (Default: flock)
That simply means Apache parsed it succesfully. Lack of syntax errors does not mean conformance to some set of goals, even if you know what those goals are.
Yikes! This is long!
So's httpd.conf . ;-)