Fixing 403 Forbidden on alias directory with Apache

后端 未结 11 1134
隐瞒了意图╮
隐瞒了意图╮ 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:46

    After lots of time waste i fixed the issue and i wanted to share to save your time.

    All the gentelmen above and on other posts has some correct parts in their answers but below is the sum

    In your "/etc/apache2/httpd.conf" file:

    1- change your document root

    Original: DocumentRoot "/Library/WebServer/Documents"
    Change to: DocumentRoot "/Users/yourname/www"
    

    2- change

    Original:

    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>
    

    Change to:

    <Directory /Users/yourname/www>
        Options FollowSymLinks Includes ExecCGI
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>
    

    3- Change:

    Original:

    <Directory "/Library/WebServer/Documents">
    

    Change to:

    <Directory "/Users/yourname/www">
    

    4- Finally, you might not need this step if you are the supper user, this is to set the right permition on your new root folder

    chmod 755 /Users/yourname/www
    

    Hope this will help

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

    Here's what fixed it for me:

    in /etc/apache2/httpd.conf

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    
        # REMOVE THESE LINES
        #Order deny,allow
        #Deny from all
    
        # ADD THIS LINE
        Require all denied
    </Directory>
    

    This change implements changes made in the apache update from 2.2 to 2.4. The OSX Yosemite update brought the apache update with it (PSA: if you're planning on upgrading to Yosemite, budget yourself a week to fix everything it breaks).

    The weird thing is that I already got apache 2.4 working, and suddenly it breaks again....

    PSA: if you're planning on upgrading to Yosemite, budget yourself a week to fix everything it breaks

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

    I had to revert my apache config file and then set up the server again. found this useful: https://apple.stackexchange.com/questions/41143/how-to-revert-default-mac-apache-install-to-original

    0 讨论(0)
  • 2020-12-08 15:02

    I was just having this exact same issue. What I found was SE_Linux was enabled, and the security context of the files in my Aliased directory was incorrect, missing httpd_sys_content_t.

    You can view the security context with ls -Z. If your files/folders don't have httpd_sys_content_t then apache won't server them up! You can add the proper context with something like chcon -R --type=httpd_sys_content_t /new_html_directory. This will change the context of the files currently in the directory, but not any files that are added afterwards (for that you'll need to work with semanage). Your other option is to just leave the files under /var/www.

    0 讨论(0)
  • 2020-12-08 15:03

    It certainly does look right, do a sanity check.

    • you restarted apache

    • check group and user ownership

    • I think the quotes can be removed

    • there is something in /Users/user/Documents/example ?

    • try 777

    -sean

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