符号链接的 MAMP 文件夹导致 403 Forbidden

发布于 2024-10-22 22:33:40 字数 314 浏览 4 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

当梦初醒 2024-10-29 22:33:40

Apache 中还有 FollowSymlinks 选项,该选项通常默认情况下处于禁用状态。您可以通过执行以下操作来启用它

Options +FollowSymlinks

There's also the FollowSymlinks option in Apache, which is generally disabled by default. You can enable it by doing

Options +FollowSymlinks
红尘作伴 2024-10-29 22:33:40

这有点老套,但我之前遇到过这个问题,虽然解决方案不一定有很大意义,但它对我有用:

  1. sudo su 假设用户 (例如,如果您的网络服务器以 nobody 身份运行,请使用 nobody
  2. 如果 #1 是一个用户,其 shell 类似于 /sbin/nologin,暂时使用 usermod 将其 shell 更改为您可以使用的内容,例如 /bin/bash之前 sudoing 作为他们的
  3. 符号链接作为用户而不是root 或任何用户执行此操作,如之前
  4. 重置重置 #2 中所做的任何更改

由于符号链接默认为 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:

  1. sudo su <username> to assume the user (eg, if your webserver is running as nobody, use nobody
  2. If #1 is a user whose shell is something similar to /sbin/nologin, temporarily use usermod to change their shell to something you can use, like /bin/bash, before sudoing as them
  3. Symlink as the user instead of root or whatever user this was done as previously
  4. Reset any changes made in #2

Since 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文