Symlinked MAMP Folder Causing 403 Forbidden

2019-03-30 06:36发布

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.

2条回答
冷血范
2楼-- · 2019-03-30 07:09

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

Options +FollowSymlinks
查看更多
男人必须洒脱
3楼-- · 2019-03-30 07:29

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?

查看更多
登录 后发表回答