apache设置虚拟主机访问403禁止访问,为什么?

apache set virtual host access 403 access forbidden,why?

环境是 OS X 10.10.2 Yosemite 我是 运行 一个 XAMPP 服务器。 我的配置:

httpd.conf

<Directory />
    #Options FollowSymLinks
    #Require all granted
    AllowOverride All
    #XAMPP
    Order deny,allow
    Allow from all
</Directory>
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin luckyyulin@sina.cn
    DocumentRoot "/Applications/XAMPP/htdocs/makefriend99/1"
    ServerName makefriend99.com
    ServerAlias www.makefriend99.com
    ErrorLog "logs/makefriend99/error_log"
    CustomLog "logs/makefriend99/access_log" common
    <Directory /Applications/XAMPP/htdocs/makefriend99/1>
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin luckyyulin@sina.cn
    DocumentRoot "/Applications/XAMPP/htdocs/angular"
    ServerName ngaction.com
    ServerAlias www.ngaction.com
    ErrorLog "logs/angular/error_log"
    CustomLog "logs/angular/access_log" common
    <Directory /Applications/XAMPP/htdocs/angular>
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

主机

127.0.0.1 makefriend99.com
127.0.0.1 ngaction.com

我在添加ngation.com之前访问makefriend99.com是成功的,另外还有localhost/makefriend99/1。但是访问ngation.com、localhost/makefriend99/1和[=31=都失败了] 403访问 添加ngaction.com后禁止,makefriend99.com成功,访问localhost到makefriend99.com。 我尝试了一些网上看到的方法,但还是没有解决问题,谁能帮我解释一下原因并给出解决方案?

我明白了,它们都 运行ing 在同一个 IP。如果它们也在同一个端口上 运行,则您必须更改其中之一的端口。

首先,这个问题可能会回答它: and this:

如果第一个不起作用,试试这个:

[注意: 我不使用 XAMPP 所以这一步可能无关紧要,您可能需要自定义 CHMOD 您 [=37= 中的所有子目录] 文件]: 在某个地方,Apple 移动了 Apache WebServer 文件夹,并且出现了一系列权限错误,导致 403 访问禁止错误(包括我在内)。

我的本地主机遇到了这个问题,但我认为这里的概念是一样的。

在您的终端中: 通过以下方式转到主目录:

$ cd 

然后我们将向上目录树。

$ cd ../../ 

进入Macintosh HD盘(根目录)。 那么:

$ cd Library 

如果您键入 ls 命令,您应该会看到所有内容。然后chmod 从之前的link(见here)到WebServer 文件夹。您可能也必须对该文件夹中的所有子目录进行 chmod,但是当我遇到此错误时我没有遇到该问题。

尝试通过将 Require all granted 指令添加到特定 VirtualHost Directory 来允许访问怎么样?

        ...
        #Order deny,allow    <- You can try to remove this
        #Allow from all      <- and that if they're just a crap.
        Require all granted
    </Directory>
</VirtualHost>
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>