环境是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
除了localhost/makefriend99/1之外,我在添加ngation.com之前访问makefriend99.com是成功的。但访问ngation.com、localhost/makefriend99/1和localhost/angular的403访问失败禁止添加ngaction.com后,makefriend99.com成功,访问localhost到makefriend99.5.com。我尝试了一些在网上看到的方法,但我还没有解决问题,谁能帮我解释为什么并给出一些答案来解决它?
尝试通过将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>
首先,这个问题可以回答它:https://stackoverflow.com/a/24665604/3990714并且这个:https://stackoverflow.com/a/9117898/3990714
如果第一个不起作用,请尝试以下操作:
[注意:我不使用XAMPP,所以这一步可能无关紧要,您可能需要习惯地CHMOD XAMPP文件中的所有子目录]:在此过程中,苹果移动了Apache WebServer文件夹,出现了一系列权限错误,导致403访问禁止错误(包括我)。
我在本地主机上遇到了这个问题,但我认为这里的概念是一样的。
在您的终端中:转到主目录通过:
$ cd
然后我们将进入目录树。
$ cd ../../
要访问Macintosh HD磁盘(根目录)。然后:
$ cd Library
如果您键入ls
命令,您应该可以看到所有内容。然后从上一个链接(见此处)chmod到WebServer文件夹。您可能还需要对该文件夹中的所有子目录进行chmod,但当我遇到此错误时,我并没有遇到这个问题。
我看到了,它们都在同一个IP上运行。如果它们也在同一个端口上运行,则必须更改其中一个的端口。
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>