将Apache设置为允许访问不在文档根目录下的目录 [英] Set Apache to allow access for a directory not under document root

查看:79
本文介绍了将Apache设置为允许访问不在文档根目录下的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Apache中唯一的虚拟主机以/var/www/html作为其文档根,该html是到/home/yanzs/web/some-project/之类的符号链接.我这样做是为了可以轻松地在新的Web项目上工作,而无需在apache中创建新的虚拟主机.所以这是我的问题,当我访问localhost时,它说

My only virtual host in Apache has /var/www/html as its document root, that html is a symbolic link to something like /home/yanzs/web/some-project/. I am doing this so that I can easily work on a new web project without create a new virtual host in apache. So here is my problem, when I access localhost, it says

Forbidden

You don't have permission to access / on this server.

如何为该"/home/yanzs/web/some-project/"目录设置权限,或者更好地为其父目录"/home/yanzs/web/"设置权限?

How can I set permissions for that "/home/yanzs/web/some-project/" directory, or better its parent directory "/home/yanzs/web/"?

这是/var/www/目录的默认设置,"FollowSymLinks"选项是否自动为/var/www下的符号墨迹的目标目录设置权限?

Here is the default setting for /var/www/ directory, does the FollowSymLinks option automatically set permissions for directories that are the targets of symbolinks under /var/www?

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

更新:我还尝试使用

Update: I also tried to use the Alias setting, does not work either. Update 2: If I set the document root as /var/www/html, and create a symbolic link under html directory, pointing to /var/www/project. Then it works, and the Alias method works too. It seems that it has something todo with the owner or other file permission settings. All files and folders under /var/www are owned by root, while those under /home/yanzs/web are owned by yanzs.

解决方案:

事实证明,对所有父目录的许可也很重要.父目录之一是从Windows复制的,默认情况下没有所需的权限.有关更多详细信息,请参见(13)权限被拒绝.吸取的教训是,即使您知道权限与浏览器的输出相关,也永远不会忘记检查错误日志.

It turns out that permission on all parent directories matters, too. One of the parent directory is copied from Windows and does not have the required permission by default. See (13) Permission Denied for more details. One lesson learned is never forget to check the error logs, even if you know permissions are relevant from output of browser.

推荐答案

事实证明,所有父目录的权限也很重要.父目录之一是从Windows复制的,默认情况下没有所需的权限.有关更多详细信息,请参见(13)权限被拒绝.吸取的教训是,即使您知道权限与浏览器的输出相关,也永远不会忘记检查错误日志.

It turns out that permission on all parent directories matters, too. One of the parent directory is copied from Windows and does not have the required permission by default. See (13) Permission Denied for more details. One lesson learned is never forget to check the error logs, even if you know permissions are relevant from output of browser.

这篇关于将Apache设置为允许访问不在文档根目录下的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆