符号链接的 MAMP 文件夹导致 403 Forbidden
我的 MAMP 根目录中有一个文件夹“site”。我将其符号链接到 ~/Documents/Dropbox/site 中的文件夹,因此“site”中发生的任何内容都会传输到 Dropbox。
但是,当我这样做时,在尝试查看 localhost/site 时收到 403 禁止错误 - 这是一个问题吗,因为我正在使用 PHP,我应该修复 php.ini,或者这是一个问题吗? httpd.conf 有问题吗?
在 httpd.conf 中,我将 AllowOverride
设置为 None
。
感谢您提前的任何答复。
I have a folder in my root MAMP directory, "site". I have that symlinked to a folder in ~/Documents/Dropbox/site, so whatever happens in "site" gets transferred to Dropbox.
However, when I do this, I get a 403 forbidden error when trying to view localhost/site
- is this a problem because I'm using PHP and I should fix php.ini, or is this an httpd.conf problem?
In httpd.conf, I have AllowOverride
set to None
.
Thanks for any answers in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Apache 中还有
FollowSymlinks
选项,该选项通常默认情况下处于禁用状态。您可以通过执行以下操作来启用它There's also the
FollowSymlinks
option in Apache, which is generally disabled by default. You can enable it by doing这有点老套,但我之前遇到过这个问题,虽然解决方案不一定有很大意义,但它对我有用:
sudo su
假设用户 (例如,如果您的网络服务器以nobody
身份运行,请使用nobody
/sbin/nologin
,暂时使用usermod
将其 shell 更改为您可以使用的内容,例如/bin/bash
,之前 sudoing 作为他们的由于符号链接默认为 0777,因此只要目标目录也具有足够的权限(0644 就可以),任何正常进程都具有读取访问权限 - 出于某种原因 Apache给我带来了问题。一旦我以相关用户的身份创建了链接,它就像一个魅力一样!
编辑:这几乎是不言而喻的,但我假设您自己通过终端验证了该链接。确保链接正确,对吗?
This is a bit hacky, but I had this problem before and while the solution didn't necessarily make a whole lot of sense, it worked for me:
sudo su <username>
to assume the user (eg, if your webserver is running asnobody
, usenobody
/sbin/nologin
, temporarily useusermod
to change their shell to something you can use, like/bin/bash
, before sudoing as themSince symlinks are by default 0777, any normal process has read access provided that the destination directory is also of sufficient permissions (0644 would be fine) - for some reason Apache gave me problems with that to. Once I created the link as the user in question, it worked like a charm. HTH!
Edit: also, this almost goes without saying, but I'm assuming you verified the link yourself via a terminal to make sure that the link is correct, right?