Re: First CGI Setup
Should not try to give people advice at two in the morning. I said 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. And I failed to mention the permissions on the files. Putting the files in the apache user group allows you to remove the read (static html) and execute (cgi) permissions for others if you want, which shores things up a bit. I don't remember if Apple gives you an apache group, but that's easy enough to add with netinfo if they don't. And I said 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. But I should have said I don't use extensions with perl, only with php, because that's the way php is built. (But I don't use php at home, which is kind of ironic. :-/) My reason for confining executables to a specific set of directories is somewhat related to my reason for not using HFS on web-facing partitions. It allows me a greater level of confidence that I know which files the server is going to expose to the web and how. Less to keep track of. Less chance of mistakenly treating a non-cgi file as an executable, and less chance of spilling source code through some slip in the configuration. (And how's that for trying to keep this on-topic?)
Re: First CGI Setup
Chris Devers wrote: On Sat, 12 Mar 2005, Joel Rees wrote: (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.) Try this: $ cat ~/bin/stamp #!/bin/bash # # stamp is a utility which makes a backup of a conf file [ $# -ne 1 ] echo usage: `basename $0` filename exit 100 old=$1 new=$1.`date +%Y%m%d`.$$ [ ! -f $old ] echo $old does not exist exit 100 cp $old $new status=$? [ -x $new ] chmod -x $new exit $status $ It's crude, but it works well enough. $ cd /etc/httpd $ sudo stamp httpd.conf # I get a file like httpd.conf.20050311.15629. $ vim httpd.conf apachectl configtest # I make a royal mess of things. Damn. $ cp httpd.conf.20050311.15629 httpd.conf $ apachectl configtest # All is right with the world again. Something like CVS / SVN / BitKeeper would be better, but not easier. Nice. You could also just op for RCS until you can get a more managed solution up, it works well enough for this type of thing and only (or not even) requires an RCS directory be created, and for you to follow the standard procedures, co -l filename ... make edits ci -u -M filename Pretty simple stuff. It appears rcs comes with Mac OS X, or at least when the dev tools are installed. man rcs For more info. The others are excellent, but they can be overkill for simple, non-distributed, configuration files. http://danconia.org
Re: First CGI Setup
On Mar 9, 2005, at 5:19 PM, Sherm Pendley wrote: On Mar 9, 2005, at 5:03 PM, Mike Lesser wrote: # To use CGI scripts: # #AddHandler cgi-script .cgi That doesn't do much when it's commented out. ;-) That's why I included it - the web article told me to uncomment it, but when I did, all I got were permission errors. So normally this would be uncommented?
Re: First CGI Setup
I thought by default OS X has the cgi setup automatically. I didn't have to do anything, just turned on the web server. And put the perl script in the CGI-EXECUTABLES folder and it works. I've seen comments online to this effect; that's why I think there's some fundamental issue with what I did to httpd. I don't necessarily trust a single article to be correct - or timely. I think that whatever is the contemporary solution is what I want. Is that to make the default solution work, and what do I need to repair? Or is there a reference to how I can make that work? M
Re: First CGI Setup
I thought by default OS X has the cgi setup automatically. I didn't have to do anything, just turned on the web server. And put the perl script in the CGI-EXECUTABLES folder and it works. That works, yes - but it's not what Mike wants to do. On many servers, files with a .cgi extension are run as CGI scripts, regardless of what directory they're in. Mike asked how to enable that behavior. Ted, I don't know exactly -what- I'm trying to do! ;-) I believe that I should have whatever is the most common setup for home development, but I don't know if that is the same as the default Mac setup, or if they conflict in some way. I can't make any assumptions really. If I should be using scripts with a cgi extension in my Sites folder, because that's the easy way to get started, then that's great. It looks like I may have broken that behavior by following the articles, and need to do some repair on httpd.conf. I figured I should post all the stuff I messed with, so see if any of it was stupid. Also Is there any reason why I would want to go in a particular direction with regard to cgi extensions or html /shtml? While I'm sure that this is the kind of stuff I'll eventually be familiar with, I don't want to create extra headaches or compat problems early on. M
Re: First CGI Setup
On Mar 10, 2005, at 10:15 AM, Mike Lesser wrote: I don't know exactly -what- I'm trying to do! ;-) Then how do you expect us to know exactly how to help you do it? I believe that I should have whatever is the most common setup for home development, If you're writing something that will need to be installed and supported on that setup, then that's what you should have. Otherwise, it depends on how your deployment server is configured. If it uses a /cgi-bin directory, use that on your development machine. If it uses .cgi files in no particular place, use that on your dev. machine. There's no reason you need to decide on one or the other, either - Apache can easily handle both possibilities at the same time. That gives you the freedom to write either way, depending on how your target server is configured. Also Is there any reason why I would want to go in a particular direction with regard to cgi extensions or html /shtml? It depends on the circumstances. If you need to drive a nail, use a hammer. To turn a screw, use a screwdriver. For a bolt, use a wrench. sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: First CGI Setup
On Mar 10, 2005, at 9:58 AM, Mike Lesser wrote: On Mar 9, 2005, at 5:19 PM, Sherm Pendley wrote: On Mar 9, 2005, at 5:03 PM, Mike Lesser wrote: # To use CGI scripts: # #AddHandler cgi-script .cgi That doesn't do much when it's commented out. ;-) That's why I included it - the web article told me to uncomment it, but when I did, all I got were permission errors. The permission error you got were entirely unrelated. They're actually a *good* sign - it means that Apache is correctly configured and trying to run the script as a CGI, but can't do it because the file permissions on the script are set incorrectly. You need to make the script executable with 'chmod', like this: chmod +x /path/to/script.cgi sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: First CGI Setup
On Thu, 10 Mar 2005, Ted Zeng wrote: It looks like I will need mod_perl. mod_perl makes me nervous. Last time I touched it, I could not make it work on Windows. The worst experience I had with Apache on Windows. Now, I just realized that I might need it because Axkit depends on it. Randal said that it is installed in OS X. I hope this is the case. I will do some search on this. There's little to research. If you look in /etc/httpd/httpd.conf, you should see these lines, mixed in with the other LoadModule and AddModule statements: #LoadModule perl_modulelibexec/httpd/libperl.so #AddModule mod_perl.c Uncomment them and you now have a mod_perl enabled Apache: LoadModule perl_modulelibexec/httpd/libperl.so AddModule mod_perl.c The mod_perl on OSX is, for the most part, exactly the same as it is on other versions of Unix: it can be flaky fiddly, and there's a lot to learn, but getting up running with it on Unix (including OSX) is a *lot* less painful than it would be on the Windows version of Apache. Or at least, that has been my experience. -- Chris Devers
First CGI Setup
Hi all. I'm busy setting up to run (okay, play with) CGIs. So for, not so great. 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, and concerned about munging up httpd.conf so badly I'll be sent away. The script.. #!/usr/bin/perl -w print Content-type: text/html\n\n; print h2Hello, World!/h2\n; ...shows up in safari with the script text, but with Hello World in the header font style! !/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). (I'm not sure what makes the most sense, just for at-home development. I'd imagine the more real-world setup is better) 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 and... # To use CGI scripts: # #AddHandler cgi-script .cgi # # To use server-parsed HTML files # #AddType text/html .shtml #AddHandler server-parsed .html 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) Yikes! This is long! Mike
Re: First CGI Setup
On Mar 9, 2005, at 5:03 PM, Mike Lesser wrote: # To use CGI scripts: # #AddHandler cgi-script .cgi That doesn't do much when it's commented out. ;-) sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: First CGI Setup
I thought by default OS X has the cgi setup automatically. I didn't have to do anything, just turned on the web server. And put the perl script in the CGI-EXECUTABLES folder and it works. ted On Mar 9, 2005, at 2:03 PM, Mike Lesser wrote: Hi all. I'm busy setting up to run (okay, play with) CGIs. So for, not so great. 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, and concerned about munging up httpd.conf so badly I'll be sent away. The script.. #!/usr/bin/perl -w print Content-type: text/html\n\n; print h2Hello, World!/h2\n; ...shows up in safari with the script text, but with Hello World in the header font style! !/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). (I'm not sure what makes the most sense, just for at-home development. I'd imagine the more real-world setup is better) 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 and... # To use CGI scripts: # #AddHandler cgi-script .cgi # # To use server-parsed HTML files # #AddType text/html .shtml #AddHandler server-parsed .html 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) Yikes! This is long! Mike
Re: First CGI Setup
On Mar 9, 2005, at 5:29 PM, Ted Zeng wrote: I thought by default OS X has the cgi setup automatically. I didn't have to do anything, just turned on the web server. And put the perl script in the CGI-EXECUTABLES folder and it works. That works, yes - but it's not what Mike wants to do. On many servers, files with a .cgi extension are run as CGI scripts, regardless of what directory they're in. Mike asked how to enable that behavior. Oh, and by the way: Because it's up-side down. Why is that? It makes replies harder to read. Why not? Please don't top-post. :-) sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org