在我的 Mac OS 10.5 机器上,我想设置一个子文件夹~/Documents
like~/Documents/foo/html
为http://localhost/foo。
我想到的第一件事就是使用 Alias,如下所示:
Alias /foo /Users/someone/Documents/foo/html
<Directory "/Users/someone/Documents/foo/html">
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
这让我得到了 403 Forbidden。在 error_log 我得到:
[error] [client ::1] (13)Permission denied: access to /foo denied
Run Code Online (Sandbox Code Playgroud)
有问题的子文件夹具有 chmod 755 访问权限。我试过指定像http://localhost/foo/test.php这样的喜欢,但这也不起作用。接下来,我尝试了符号链接路线。
进入/Library/WebServer/Documents
并创建了一个符号链接~/Documents/foo/html
。文档根有
Options Indexes FollowSymLinks MultiViews
Run Code Online (Sandbox Code Playgroud)
这仍然让我 403 Forbidden:
Symbolic link not allowed or link target not accessible: /Library/WebServer/Documents/foo
Run Code Online (Sandbox Code Playgroud)
我还需要什么来设置它?
解决方案:
$ chmod 755 ~/Documents
Run Code Online (Sandbox Code Playgroud)
通常,要共享的文件夹及其所有祖先文件夹都需要www
服务用户可以查看。