Fixing 403 Forbidden on alias directory with Apache

后端 未结 11 1091
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 14:35

I am trying to setup an alias to point to some directory on my filesystem not in DocumentRoot. Now I get a 403 Forbidden response. These are the steps taken: 1. edit http.co

相关标签:
11条回答
  • 2020-12-08 14:36

    I was having this issue on OS X too. It turned out gliptak was right, but I've some more detail to add.

    We're both attempting to configure a virtual directory for a folder under a user's home folder; I think this is why we're having the problem. In my case, I had the following setup:

    • Home folder is /Users/calrion.
    • Virtual directory folder is /Users/calrion/Path/to/www.
    • There's a symlink /Users/calrion/Path pointing to /Volumes/Other/Users/calrion/Path.

    The problem was the user and group _www (which Apache runs as on OS X) lacked execute access to /Users/calrion and /Volumes/Other/Users/calrion.

    Running chmod o+x /Users/calrion and chmod o+x /Volumes/Other/Users/calrion resolved the issue (on OS X 10.7.4).

    The rule here is that Apache requires execute access to all folders in the path in order to serve files. Without this, you'll get a HTTP 403 (forbidden).

    0 讨论(0)
  • 2020-12-08 14:37

    SELinux was the culprit for me. If you're having this issue on a linux box and your alias and file permissions are correct than try doing a "setenforce 0" to put SELinux into permissive mode. That did the trick for me.

    0 讨论(0)
  • 2020-12-08 14:39

    Check permission on /Users/user/Documents/, /Users/user/ (higher level permissions are enforced first ...)

    /bin/su into the user running Apache (like www, www-data) and cat a file in the /Users/user/Documents/example directory. That might point you to permission problems with your setup.

    0 讨论(0)
  • 2020-12-08 14:41

    Quick Solution:

    Use these commands as root on Linux:

    find /var/www -type d -exec chmod 755 {} \;
    find /var/www -type f -exec chmod 644 {} \;
    
    0 讨论(0)
  • 2020-12-08 14:42

    These are all very good answers. None of them worked for me.

    I have an alias specified in OSX server pointing to a user directory. I spent a long while chmodding and messing with _www user, adding executable permissions recursively, uninstalling macports and all sorts of stuff trying to get this to work. I tried 777. Nope. No idea why it wasn't working.

    Eventually, I just checked the "shared folder" checkbox in the Finder for that folder, and it worked, on the specified domain, with php active, the way I wanted it to. :/ ...so that was easy.

    0 讨论(0)
  • 2020-12-08 14:46

    The last straw ;) Required local in the Directory Entry...

    like

    <Directory "/Users/user/Documents/example">
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Require local
       Order allow,deny
       Allow from all
    </Directory>
    

    if everything else doesn't work (correct Alias, Directory Entry in httpd.conf and correct mod/usr/grp).

    keep in mind: if you put your site in user-space the apache user (running httpd) needs access to your home!

    0 讨论(0)
提交回复
热议问题