Recipe 5.7 Creating a CGI Directory for Each User

Problem

You want each user to have their own cgi-bin directory rather than giving them all access to the main server CGI directory.

Solution

Put this in your httpd.conf:

<Directory /home/*/public_html/cgi-bin/>     Options ExecCGI     SetHandler cgi-script </Directory>

Discussion

You can't use ScriptAlias in this case, because for each user, the first argument to ScriptAlias would be different. Using ScriptAliasMatch would also be impossible. The second argument to ScriptAliasMatch must be a constant string.

This recipe lets each user put CGI scripts in her own personal web space. Files accessed via URLs starting with:

http://www.example.com/~username/cgi-bin/

are treated as CGI scripts.

If you have suexec enabled, CGI programs run from this target directory will be run with the userid of the user specified in the URL. For example, a CGI program accessed via the URL http://www.example.com/~rbowen/cgi-bin/example.cgi would be run as the user rbowen.

See Also

  • Recipe 8.1



Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net