PDA

View Full Version : where is cgi-bin so I can test perl scripts



bstanard
01-06-2005, 06:23 PM
I have a class of cgi/perl students, some of whom can only use Knoppix at home when not in the classroom (where we have a Redhat box). I want them to be able to run .cgi scripts through apache to test their perl scripts. They can then save the scripts in their home directory (using K menu > KNOPPIX > Configure > Create a persistent K home directory).

I cannot, however, find a cgi-bin in /var/www and, if I use sudo mkdir to create it, I cannot write to it. They can test their scripts for syntax errors (using perl -c testScript.cgi), but they cannot debug the full output from, say, test.html which calls test.cgi; this kind of debugging requires the apache server to serve the output of a perl script in .cgi form. Any ideas?

Bill Stanard

tom p
01-07-2005, 12:23 PM
Hi,

(I'm running a Debian system installed from the Knoppix CD on HD, so not everything might be accurate...)

The apache configuration lives under /etc/apache/httpd.conf, searching for cgi-bin reveals: it's configured at
/usr/lib/cgi-bin

That directory is owned by user root, so the easiest might be to alter the httpd.conf and add another ScriptAlias
directive that your students can write to.

Ciao,
Thomas

bstanard
01-07-2005, 01:33 PM
tom p wrote: The apache configuration lives under /etc/apache/httpd.conf, searching for cgi-bin reveals: it's configured at
/usr/lib/cgi-bin

That directory is owned by user root, so the easiest might be to alter the httpd.conf and add another ScriptAlias
directive that your students can write to.

That's the part that gets me.... how can I write to a directory (/usr/lib/cgi-bin) that appears to be read only? I have had success writing only to the desktop. Am I missing something basic here?

cheers!
Bill

tom p
01-07-2005, 04:05 PM
how can I write to a directory (/usr/lib/cgi-bin) that appears to be read only? I have had success writing only to the desktop. Am I missing something basic here?


You don't need to! The directories beyond /etc (not the files though; they are symlinks) are writable;
I'd suggest to put a file "userdir.conf" into /etc/apache/conf.d/ with the following content:


AddHandler cgi-script .cgi .pl
<Directory /home/*/public_html>
Options +Includes +ExecCGI
</Directory>


Then, in your home directory create "public_html", put a cgi in there and (after starting apache) try if it works:
wget http://localhost/~knoppix/your_test_cgi_here.cgi

HTH,
Thomas

bstanard
01-10-2005, 02:00 PM
ok, and, by the way, thanks for the help so far....I cd-ed to /etc/apache/conf.d, vi-ed a file userdir.conf, and... rec'd the error message: "userdir.conf " E212: Can't open file for writing... when I tried to wq (save) the file... again and again I must be doing something wrong, for I can not save to any directory except knoppix's home directory... is there a switch I haven't flipped or something that I should be doing?
please advise
cheers!
Bill

tom p
01-10-2005, 03:52 PM
ok, and, by the way, thanks for the help so far....I cd-ed to /etc/apache/conf.d, vi-ed a file userdir.conf, and... rec'd the error message: "userdir.conf " E212: Can't open file for writing... when I tried to wq (save) the file... again and again I must be doing something wrong, for I can not save to any directory except knoppix's home directory... is there a switch I haven't flipped or something that I should be doing?
please advise
cheers!
Bill

try it as user "root" (i.e. for example from the "penguin" menu open a rootshell) and then create that file. That should work...

Ciao,
Thomas