我想让 Apache 从 提供“普通”文件/srv/http/public
,从 提供用户文件/srv/http/[user]
,因此目录可能看起来像
/srv/http
/public
index.html - Accessible at localhost/index.html
/austin
index.html - Accessible at localhost/~austin/index.html
目前,我在 Apache.conf
文件中有以下相关配置
User http
Group http
DocumentRoot "/srv/http/public"
<Directory "/srv/http/public">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
UserDir /srv/http
UserDir disabled root
<Directory "/srv/http">
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
以及以下权限/srv/http
:
drwxr-xr-x root http /srv/http
drwxr-xr-x http http /srv/http/public
-rwxr-xr-x http http /srv/http/public/index.html
drwxr-xr-x austin http /srv/http/austin
-rwxr-xr-x austin http /srv/http/austin/index.html
使用此设置,localhost/index.html
显示正常,但localhost/~austin/index.html
给出403 禁止访问!错误,无论我怎么尝试。
编辑:相关的 error_log 条目: [error] [client ::1] client denied by server configuration: /srv/http/austin/index.html
我究竟做错了什么?
哦,我认为这并不重要,但我正在使用 Arch Linux 和 Apache 2.2.19
答案1
问题在于<Directory>
用户目录的指令过于严格。
重新使用/srv/http/public
目录中的相同指令允许外界查看任何用户文件:
<Directory "/srv/http">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>