我尝试过很多方法,我已经研究了很多关于StackOverflow的问题,而且 none 的工作方式也有效!一些信息:
以下是我尝试过的网站:
Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (SO)
Apache Virtual Host is not working right (SO)
Apache VirtualHost not working (SO)
virtual host not working - Apache Web Server forum at WebmasterWorld
我的VirtualHosts文件:
<VirtualHost wrks.tk:80>
DocumentRoot "/Apps/XAMPP/htdocs/DNS"
ServerName wrks.tk
ErrorLog "/Logs/wrks.tk-error.log"
CustomLog "/Logs/wrks.tk-access.log" common
<Directory "/Apps/XAMPP/htdocs/DNS">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
它实际加载的内容(这是httpd.conf文件中的defualt目录,即“backup”目录):
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
答案 0 :(得分:0)
我要检查的事情是:
确保包含httpd-vhosts.conf
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
设置主机:
在文本编辑器中导航到Macintosh HD / private / etc / hosts,然后单击“打开”。然后添加以下行:
127.0.0.1 wrks.tk
也许可以试试:
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/DNS"
ServerName wrks.tk
ErrorLog "/logs/wrks.tk-error_log"
CustomLog "/logs/wrks.tk-access_log" common
</VirtualHost>
您可能还想再次设置localhost。
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
ServerName localhost
</VirtualHost>
很抱歉,如果其中一些路径不准确,您需要根据您的xamp文件夹结构进行检查。
我发现最简单的实现是这样的: http://iwearshorts.com/blog/adding-a-virtual-host-vhost-in-xampp-on-a-mac/