我的每个用户的主文件夹中有两个目录:.html-data
和.cgi-bin
. 第一个包含静态 (.html) 文件,第二个包含用于动态文档生成的文件。
每个用户都应该能够在 上发布.html-data
文件夹的内容以及在 上发布文件夹http://myhost.com/~<username>/
的内容。用于动态内容创建的脚本应该作为提供它们的用户来执行(例如应该作为用户 steve 来执行)。.cgi-bin
http://myhost.com/~<username>/cgi-bin/
~steve/cgi-bin/test.cgi
为此,我为 Apache 2.4 的 userdir 模块配置了以下配置:
UserDir .html-data
UserDir disabled root
<Directory "/home/*/.html-data">
RewriteEngine On
RewriteBase /~username/
RewriteRule "^/cgi-bin/(.*)" "../../.cgi-bin/$1"
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
<Directory "/home/*/.cgi-bin">
Options ExecCGI
SetHandler cgi-script
Satisfy any
</Directory>
但是,这不起作用。RewriteRule 似乎是错误的。如何引用用户的.cgi-bin
目录?
这是错误日志:
[Thu Aug 04 20:14:17 2016] [trace3] mod_rewrite.c(477): [client 10.0.2.2:44058] 10.0.2.2 - - [myhost.com/sid#19f4a48][rid#1a639b0/initial] [perdir /home/*/.html-data/] add path info postfix: /home/steve/.html-data/cgi-bin -> /home/steve/.html-data/cgi-bin/hello.cgi
[Thu Aug 04 20:14:17 2016] [trace3] mod_rewrite.c(477): [client 10.0.2.2:44058] 10.0.2.2 - - [myhost.com/sid#19f4a48][rid#1a639b0/initial] [perdir /home/*/.html-data/] applying pattern '^/cgi-bin/(.*)' to uri '/home/steve/.html-data/cgi-bin/hello.cgi'
[Thu Aug 04 20:14:17 2016] [trace1] mod_rewrite.c(477): [client 10.0.2.2:44058] 10.0.2.2 - - [myhost.com/sid#19f4a48][rid#1a639b0/initial] [perdir /home/*/.html-data/] pass through /home/steve/.html-data/cgi-bin