[lug] cgi-bin Apache

D. Stimits stimits at idcomm.com
Sun Dec 10 17:34:49 MST 2000


John Starkey wrote:
> 
> Some of the things I told you were wrong. 1) I never finished setting up
> ~user/cgi-bin and 2) ScriptAlias. All the accounts I host have domains. I
> have a couple regular users but they aren't doing the web.
> 
> I did start to set it up (~user/cgi-bin) just now and here's what I came
> up with. www.apache.org/docs/howto/cgi.html is what I'm using, as well as
> Apache Unleashed, which only covers the server cgi-bin as far as I can
> tell.
> 
> I have Apache pointing to the correct dir by adding AllowOverride Options
> (in the main server config section) and in a /home/*/cgi-bin Directory
> container, within the mod_userdir section we discussed, I added Options
> +ExecCGI.

Interestingly enough (or maybe not), a search at apache.org fails to
find anything related to mod_userdir, yet it is in my httpd.conf by
default.

Background info: I have 9 subdirectories of /home/, being home1, home2,
home3, ...home9:
/home/home1/users...
/home/home2/users...
...
/home/home9/users...

Along with that each group has its own group ID. One home directory is
for full accounts that belong only to me. Another (home2) is for web
experiments (home2), which has almost no privileges aside from shell
logins and web access (it's as close to "nobody" as it can get without
destroying the use of it as a shell account). No other group has web
server access. Another home# is for ftp accounts for outside users,
others are for special purpose or general temporary accounts. I get
better control this way (my home1 users are granted group access to the
others so it isn't a problem). But for purposes here, /home/home2/ is
the relevant home directory base.

I used what you pointed out and managed to solve the problem. In the
main httpd.conf I added:
ScriptAlias /~web_user/cgi-bin/ "/home/home2/web_user/cgi-bin/"
<Directory "/home/home2/web_user/cgi-bin">
    AllowOverride Options
    Options +ExecCGI
    Order allow,deny
    Allow from all 
</Directory>

The 2 tricks were that (1) ScriptAlias can't be added within a
<Directory...> </Directory> tag pair, nor within a .htaccess, and must
be added globally in the main httpd.conf; and (2) Naming /cgi-bin/ has
no effect if it is prefixed by ~web_user...I had to name it fully as
"/~web_user/cgi-bin/". So now I can do this:
http://localhost/~web_user/cgi-bin/test.cgi

Voila!

> 
> I'm recieving "Internal Server Error" messages. According to error_log
> it's being caused by a "premature end of script" but the script is working
> in my other cgi-bins. So I think it's an suExec problem. Regardless it is
> pointing to that file and not showing the script so it is trying to
> execute the file.

Try deleting the last line of your cgi script (assuming it is blank), or
appending a new line in vi and writing.

> 
> Sorry about the inconvenience, I hope this may help a little more better
> :}. I'm gonna try to get back to it later this week. If I get it working
> I'll let you know.

You've been quite helpful, thanks! I am still curious about the
mod_userdir though. Since I couldn't find it listed at apache.org, let
me know if you find any other web links to configuring it.

> 

D. Stimits, stimits at idcomm.com




More information about the LUG mailing list