我使用基本的Apache HTTPdconfiguration来configuration我的开发环境。
但是,为了避免经常出现问题,我想将我的testingURL映射到我的开发文件夹。
我正在使用Ubuntu。
我的开发path位于以下示例path下:
/home/myusername/myworkspace/hptargetpath/src/pages
考虑以下符号链接映射:
#ls -l /opt/share/www/mydevelopmentrootpath: lrwxrwxrwx 1 root root 77 2011-02-13 18:53 /opt/share/www/mydevelopmentrootpath -> /home/myusername/myworkspace/hptargetpath/src/pages
通过这个文件夹映射,我configuration了Apache HTTPd以下configuration:
<VirtualHost *:*> ServerName local.server.com ServerAdmin [email protected] DirectoryIndex index.html DocumentRoot /opt/share/www/mydevelopmentrootpath <Directory /opt/share/www/mydevelopmentrootpath/ > Options +Indexes Options +FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>
但是,当我要访问地址http://local.server.com/index.html下的index.html时,我收到了403 Forbidden错误。
403 Forbidden You don't have permission to access /index.html on this server.
在httpddebugging日志上,我检查了以下消息:
[Sun Feb 13 19:34:47 2011] [error] [client 127.0.1.1] Symbolic link not allowed or link target not accessible: /opt/share/www/mydevelopmentrootpath
我在想,这个问题是由一些path权限产生的。 这不是对目录的直接许可,而是path中的一些中间目录。
有一个关于httpd核心选项的指令:
SymLinksIfOwnerMatch The server will only follow symbolic links for which the target file or directory is owned by the same user id as the link.
但是,我testing没有影响。
有人可以帮助我吗? 我认为这是一个简单的开发环境configuration。
最好的祝福,
和过去
为了遵循这个符号链接,apache需要为/home/myusername/myworkspace/hptargetpath/src/pages所有父目录执行权限。 你可以授予这个权利
chmod o+x /home chmod o+x /home/myusername chmod o+x /home/myusername/myworkspace chmod o+x /home/myusername/myworkspace/hptargetpath chmod o+x /home/myusername/myworkspace/hptargetpath/src chmod o+x /home/myusername/myworkspace/hptargetpath/src/pages
在大多数情况下,这有帮助。
我们昨天也有类似的问题。 我们可以解决它是将符号链接所有权更改为用户级别:
chown -h <user>.<group> <symlink>
Apache识别符号链接的所有权,并提出错误,如果符号链接所有权不适合。 在error_log中,您只能阅读“符号链接不允许或链接目标不可访问”。 不要忘了-h选项,因为否则更改目标所有权。