From owner-freebsd-questions@FreeBSD.ORG Fri Aug 20 15:10:14 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E43E416A4CF for ; Fri, 20 Aug 2004 15:10:13 +0000 (GMT) Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net [66.167.251.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 779D843D3F for ; Fri, 20 Aug 2004 15:10:13 +0000 (GMT) (envelope-from wmoran@potentialtech.com) Received: from working.potentialtech.com (pa-plum-cmts1e-68-68-113-64.pittpa.adelphia.net [68.68.113.64]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by internet.potentialtech.com (Postfix) with ESMTP id 7E64769A71; Fri, 20 Aug 2004 11:10:12 -0400 (EDT) Date: Fri, 20 Aug 2004 11:10:10 -0400 From: Bill Moran To: Mark Jayson Alvarez Message-Id: <20040820111010.7b74594b.wmoran@potentialtech.com> In-Reply-To: <20040820145201.68204.qmail@web51603.mail.yahoo.com> References: <20040820145201.68204.qmail@web51603.mail.yahoo.com> Organization: Potential Technologies X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386-portbld-freebsd4.9) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: Humble questions for web developers in freebsd. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2004 15:10:14 -0000 Mark Jayson Alvarez wrote: > Greetings, > > I have installed the latest Apache http server > for the first time and I have just started programming > perl cgi scripts as well. It didn't brought me any > trouble installing it, but when I wrote my first > "Hello World" cgi script, I end up with an internal > server error. Eventually (through a very intensive, > sleepless researching), I was able to run it > successfully > in a browser after changing its mode to 755(whiew!). > > Questions: > 1. Do I always have to do this for every script that I > would make? I thought, apache web server will know how > to execute those files if it sees something like > #!/usr/local/bin/perl in the beginning of the file. No. Apache needs to know that those script should be executed instead of sent as-is to the browser. This is more a Unix thing than a CGI thing. Scripts should always have execute permissions on them, but Apache can be configured to work around this by identifying the type of file and handling it properly. Lots of docs available for reading, especially on Apache's config. > 2. I'm having a small clue on this one. The perl > book("Beginning Perl") told me that in a default > installation, apache is started by "nobody"(after > running"ps -aux |grep httpd", I can see at least five > httpd processes run by nobody and one that is run by > me(root).) --if it is run by nobody, then it can't run > the cgi script I have written right? Elucidate me > please. (And also those 5 nobody's) How did you install Apache? Default Apache installs on FreeBSD use user "www" and group "www" and no longer use nobody. The first Apache process has to start as root to bind to port 80, but any additional worker process should run as a non-priviledged user. (usually user www on FreeBSD) > 1. (hmm.. just curious) Can't I start writing a perl > program or just a plain text file that already has a > 755 mode?(ex: vi -m 755... hello.plx) I don't see why not. > 2. Do you know how can I run a perl program in freebsd > without having it preceded with the word perl? > (I tried changing its mode to 755 and also putting it > to /usr/local/bin but it didn't work(don't laugh at me > please.. I'm still learning:=). Just call the program. If it has X permissions for available for you (the user you're trying to run it as) it will notice the #!/usr/bin/perl at the head of the file an user perl to interpret the script. I noticed you had #!/usr/local/bin/perl in your earlier comments. Use "which perl" to find out the path to perl on your system and use that. If that first line has the wrong path, your scripts won't run. > 3. If you happened to be one, I'm already having a > picture of how web developers are creating web pages > or cgi scripts(because the whole apache directory is > owned by the root, they would have to write them > outside and then transfer them inside when they are > finish, am I correct?? Because what I did was, change > the ownership of the entire apache directory for me to > be able to save an html file or a cgi script in it... Make each directory owned by the user doing development, and the group of the web server (usually www, although it appears to be nobody in your case). Then the user can have full access to the file, and you can give the group r-x permissions so it can read and execute it. > 4. Do you happen know any good link where I can learn > how to write shell scripts so that I may be able to > start an application at boot time by putting it in > "/usr/local/etc/rc.d" (ex: httpd) The existing shell scripts in that directory, placed there by programs you installed are a good start. Otherwise, there's a section in the handbook on the rcng system that's pretty informative. -- Bill Moran Potential Technologies http://www.potentialtech.com