Apache 如何让虚拟主机与XAMPP一起工作?
我昨天刚在我的Win7机器上重新安装了XAMPP。我正在做一个拉威尔的项目。我安装了当前版本的Laravel,然后在本地机器上设置虚拟主机。当我转到我设置的url(jrd_dnd_tools.localhost)时,我会收到一条错误的网关消息。如果我转到localhost,我会得到url应该指向的站点。我以前设置过虚拟主机,但不知道为什么会发生这种情况。我肯定我错过了一些愚蠢的事情,但我不知道是什么 httpd-vhosts.confApache 如何让虚拟主机与XAMPP一起工作?,apache,xampp,virtualhost,Apache,Xampp,Virtualhost,我昨天刚在我的Win7机器上重新安装了XAMPP。我正在做一个拉威尔的项目。我安装了当前版本的Laravel,然后在本地机器上设置虚拟主机。当我转到我设置的url(jrd_dnd_tools.localhost)时,我会收到一条错误的网关消息。如果我转到localhost,我会得到url应该指向的站点。我以前设置过虚拟主机,但不知道为什么会发生这种情况。我肯定我错过了一些愚蠢的事情,但我不知道是什么 httpd-vhosts.conf <VirtualHost *:80>
<VirtualHost *:80>
ServerAdmin webmaster@jrd_dnd_tools.localhost
DocumentRoot "C:\Users\Joey\Web\jrd_dnd_tools/public"
ServerName jrd_dnd_tools.localhost
ServerAlias www.jrd_dnd_tools.localhost
ErrorLog "logs/jrd_dnd_tools.localhost.log"
CustomLog "logs/jrd_dnd_tools.localhost.log" common
<Directory "C:\Users\Joey\Web\jrd_dnd_tools/public">
AllowOverride All
Order Allow,Deny
Allow from all
## --New way of doing it
Require all granted
</Directory>
</VirtualHost>
您所犯的错误是,
*:80
,因为虚拟主机从不使用通配符。相反,您可以执行jrd\u dnd\u tools.localhost
。下面是我的虚拟主机设置,我为演示做的
还要注意我在文档根和目录中使用的目录分隔符
做这两个改变,你的虚拟主机将像一个魅力
<VirtualHost t.com:80>
ServerAdmin webmaster@t.com
DocumentRoot "C:/xampp/htdocs/t"
ServerName t.com
ServerAlias t.com
## ErrorLog "logs/jrd_dnd_tools.localhost.log"
##CustomLog "logs/jrd_dnd_tools.localhost.log" common
<Directory "C:/xampp/htdocs/t">
AllowOverride All
Order Allow,Deny
Allow from all
## --New way of doing it
Require all granted
</Directory>
</VirtualHost>
服务器管理员webmaster@t.com
DocumentRoot“C:/xampp/htdocs/t”
服务器名t.com
服务器别名t.com
##ErrorLog“logs/jrd_dnd_tools.localhost.log”
##CustomLog“logs/jrd_dnd_tools.localhost.log”通用
允许超越所有
命令允许,拒绝
通融
##——新的做法
要求所有授权
可能我知道它看起来可能重复,但我搜索了Stack Exchange和Google,没有找到解决问题的答案C:\Users\Joey\Web\jrd\u dnd\u tools/public
-您混合了前后斜杠,用于DocumentRoot
和
。不确定这是否会导致“坏网关”,但肯定是错误的-尝试修复所有反斜杠。还要检查错误日志以了解更多详细信息。如果您使用代理,请检查浏览器配置,并使用您需要使用的本地名称提供“no use proxy for…”(并将www…别名添加到主机文件中)。我是这样设置的,但现在我收到了一个错误的请求。@joyed473-我希望您在.hosts
文件中也做了更改。类似于127.0.0.1 t.com
。我的主机文件与原始文件中的相同
<VirtualHost t.com:80>
ServerAdmin webmaster@t.com
DocumentRoot "C:/xampp/htdocs/t"
ServerName t.com
ServerAlias t.com
## ErrorLog "logs/jrd_dnd_tools.localhost.log"
##CustomLog "logs/jrd_dnd_tools.localhost.log" common
<Directory "C:/xampp/htdocs/t">
AllowOverride All
Order Allow,Deny
Allow from all
## --New way of doing it
Require all granted
</Directory>
</VirtualHost>