[vox-tech] cgi-bin in user home dirs

Tim Riley vox-tech@lists.lugod.org
Mon, 10 Feb 2003 16:39:20 -0800


Jim Angstadt wrote:

> --- Tim Riley <timriley@timriley.net> wrote:
> >
> >
> > Jim Angstadt wrote:
> >
> > > Hi All,
> > >
> > > I'm trying to allow user accounts to have their
> > own
> > > cgi-bin directory on a RH 7.2, apache box at my
> > home.
> > >
> > > For testing, I have file test.cgi.
> > > (See below for file and permissions.)
> > >
> > > When the file is placed in /var/www/cgi-bin it
> > works.
> > > Meaning, when I open a browser and key in
> > >    http://localhost/cgi-bin/test.cgi
> > > I see "Hello There".
> > >
> > > When placed in /home/ja/public_html/cgi-bin it
> > does
> > > not work.  When I key in
> > >    http://localhost/~ja/cgi-bin/test.cgi
> > > I have gotten either of two responses
> > >    1. the script text
> > >    2. an error msg: "Forbidden You don't have
> > >    permission to access /~ja/cgi-bin/test.cgi
> > >    on this server.
> >
> > I've never done this, but based upon the Apache
> > configuration file syntax, this should be possible.
> > Note: this might be close but not exact.
> >
> > Edit httpd.conf (mine's in /etc/httpd/conf)
> > Got to the line that says: ScriptAlias /cgi-bin/
> > "/var/www/cgi-bin/"
> > Below it add a new line that says: ScriptAlias
> > /cgi-ja/
> > "/home/ja/cgi-bin/"
>
> Hi Tim,
>
> Thanks for the help.  I added both items to
> httpd.conf and then restarted httpd.  Then I
> keyed http://localhost/~ja/cgi-ja/test.cgi into
> the browser location bar and got a "Not Found"
> response.
>

This is expected. CGI scripts are not intended to
be called directly from the browser, instead they
are executed from the HTML post operation
located inside of a <FORM action="/cgi-ja/...">
tag.

I think your intention is to have different users
access their HTML files from their home directories.
The key Apache configuration tag for this is "DocumentRoot".

This might be achieved by linking
an html subdirectory in their home directory
to where ever "DocumentRoot" point to.

Example: ln -s /home/ja/html /var/www/html/ja

Again, this is just a guess.

>
> Thinking the cgi-bin dir should be directly
> under /home/ja, I moved it there, restarted
> httpt, and got the same "Not Found" msg.
>
> Then I changed the Options line of the new block
> to read: Options none ExecCGI
> and restarted httpd.  Nope.
>
> Likewise for just: Options ExecCGI
>
> It's gotta be something simple I'm missing.
>
> ---
> Jim
> (I'll stop shooting in the dark now.)
>
> >
> > Below that should be a directory tag: <Directory
> > "/var/www/cgi-bin">
> > with the cgi permissions. Clone that tag block for
> > your new
> > "/home/ja/cgi-bin" directory.
> >
> > To execute ja's scripts, prefix the HTML action tag
> > with "/cgi-ja/".
> >
> >
> > >
> > >
> > > I've tried changing cgi to pl, which had no
> > effect.
> > >
> > > Have also messed with /etc/httpd/conf/httpd.conf
> > > without success.  That's not too surprising.
> > > I don't know what I'm doing.  But it didn't stop
> > > me from hacking away.
> > >
> > > Google and tldp.org did not turn up anything that
> > > helped.  Neither did an Apache book I have.
> > >
> > > A detailed, simple tutorial would be nice.
> > >
> > > ---
> > > Jim
> > >
> > > # ---------- test.cgi
> > > #!/usr/bin/perl
> > > use strict;
> > > use warnings;
> > >
> > > use CGI qw(:standard);
> > > use CGI::Carp qw/fatalsToBrowser/;
> > >
> > > print header();
> > > print start_html("Testing");
> > >
> > > print h1("Hello There");
> > > print end_html;
> > >
> > > # ---------- permissions for test.cgi
> > > # edited for readability
> > > #
> > > Script started on Mon Feb 10 10:25:51 2003
> > >
> > > ]0;ja@localhost:~[ja@localhost ja]$ ls -l
> > > drwxr-sr-x    6 ja       apache       4096 Feb  7
> > > 16:23 public_html
> > >
> > > ]0;ja@localhost:~[ja@localhost ja]$ cd
> > public_html/
> > > ]0;ja@localhost:~/public_html[ja@localhost
> > > public_html]$ ls -l
> > > drwxr-sr-x    8 ja       apache       4096 Feb  7
> > > 11:33 cgi-bin
> > >
> > > ]0;ja@localhost:~/public_html[ja@localhost
> > > public_html]$ cd cgi-bin/
> > >
> > ]0;ja@localhost:~/public_html/cgi-bin[ja@localhost
> > > cgi-bin]$ ls -l test*
> > > -rwxr-xr-x    1 ja       apache        190 Feb  9
> > > 17:27 test.cgi
> > >
> > > Script done on Mon Feb 10 10:26:39 2003
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail Plus - Powerful. Affordable. Sign up
> > now.
> > > http://mailplus.yahoo.com
> > > _______________________________________________
> > > vox-tech mailing list
> > > vox-tech@lists.lugod.org
> > > http://lists.lugod.org/mailman/listinfo/vox-tech
> >
> > _______________________________________________
> > vox-tech mailing list
> > vox-tech@lists.lugod.org
> > http://lists.lugod.org/mailman/listinfo/vox-tech
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech