使用Apache以特定用户的身份执行CGI脚本

我想在我的web服务器上运行一个特定的(perl)CGI脚本。 这个工作是合理的,但是如果CGI脚本将以当前authentication的用户身份运行,那么这将非常好。

有没有办法做到这一点,例如与包装和sudo

虚拟主机configuration如下:

DocumentRoot /path/to/script <Directory /path/to/script> Options FollowSymLinks +ExecCGI AddHandler cgi-script .cgi AuthType Basic AuthName "Authenticate" # This authenticates against the local NIS PerlAuthenHandler Apache2::AuthenNIS PerlAuthzHandler Apache2::AuthzNIS PerlSetVar AllowAlternateAuth no Require valid-user </Directory> 

究竟是什么阻止你的应用程序以这种方式运行?

有可能做你想问什么,但是这可能是一个更好的利用你的时间来configuration一个应用程序可以作为拥有httpd进程的同一个用户运行的环境。

你只是为你的环境引入更多的复杂性,这使得debugging,保护和pipe理变得更加困难。

无论如何,要回答你的问题:看看suEXEC – http://httpd.apache.org/docs/2.0/suexec.html

回应文件,你几乎总是不会这样做。