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

时间:2015-06-30 03:36:08

标签: php apache virtualhost

环境是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和localhost / angular of 403 access  添加ngaction.com后禁止,makefriend99.com成功,访问localhost to makefriend99.com。 我已经尝试过在互联网上看到的一些方法,但我还没有解决问题,谁能帮助我解释原因并给出一些答案来解决它?

4 个答案:

答案 0 :(得分:2)

如何通过将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>

答案 1 :(得分:1)

首先,这个问题可能会回答:https://stackoverflow.com/a/24665604/3990714而且:https://stackoverflow.com/a/9117898/3990714

如果第一个没有效果,请尝试:

[注意:我不使用XAMPP,因此此步骤可能无关紧要,您可能需要自定义CHMOD XAMPP文件中的所有子目录]: 在某些地方,Apple移动了Apache WebServer文件夹,出现了一堆权限错误,导致403 Access Forbidden Error(包括我)。

我特意在本地主机上遇到过这个问题,但我认为这里的概念是相同的。

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

$ cd 

然后我们将上到目录树。

$ cd ../../ 

进入Macintosh HD磁盘(根目录)。 然后:

$ cd Library 

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

答案 2 :(得分:0)

我看到,他们两个都在同一个IP上运行。如果它们也在同一个端口上运行,则必须更改其中一个端口。

答案 3 :(得分:0)

<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
相关问题