Vagrant 403 Forbidden

前端 未结 4 2233
一整个雨季
一整个雨季 2021-02-14 06:17

I\'ve been running Vagrant successfully for about a week. Last night I ran vagrant reload and now I can no longer access my sites.

  • VirtualBox version 4.2.16
相关标签:
4条回答
  • 2021-02-14 06:36
    cd /etc/apache2/sites-available
    for file in `ls *`; do sed 's/\(.*<\/Directory.*>\)/Require\ all\ granted\n\1/' $file > $file.new;mv $file.new $file ; done;
    

    because it worked before, I would not waste time on fix file by file

    0 讨论(0)
  • 2021-02-14 06:41

    I had the same problem when changing the DocumentRoot.

    Since you've changed your DocumentRoot to "/any/path/foo/bar", make sure you have the permissions set on "apache2.conf" for this path.

    Search for:

    <Directory /any/path/foo/bar>
    

    in apache2.conf

    And add a new block like this:

    <Directory /any/path/foo/bar>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
    

    And my guess is that everything is gonna be fine!

    0 讨论(0)
  • 2021-02-14 06:49

    My hunch is that this is not a vagrant issue at all but solely an Apache configuration glitch. There are a few things I can think to check.

    First, obviously, is to confirm that the user that apache is running under has read and execute permissions for the DocumentRoot folder.

    Since you mentioned Apache 2.4, there have been changes in the configs from 2.2. Make sure your Allow from all statements now read Require all granted. (If you were still on 2.2, you'd want to make sure they said Allow from all instead of Deny from all.) In either case, you can set this in each <VirtualHost> individually, or set a default in your <Directory /> block of the main httpd.conf file.

    Getting more obscure, you could check for selinux, although I'm pretty sure this isn't present in Ubuntu by default. (It is in CentOS, for example.)

    0 讨论(0)
  • 2021-02-14 06:51

    This is solved and in the end came down to some very simple things.

    • Use "Require All granted" instead of "Allow from All"
    • Put each websites' content at the same level namely /vagrant/Sites/default, /vagrant/Sites/test, /vagrant/Sites/real-site
    • Add .conf extension to vhost names such as test.conf and real-site.conf
    • Add AllowOverride All to vhosts to respect sites' .htaccess file (I realize that was in my original post, it got lost as I tried to solve this)

    All very basic things that eluded me for a better part of a week. I hope this can help someone else.

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