命名虚拟主机在 xampp windows 中不工作
Named virtual host not working in xampp windows
我在 extra\httpd-vhosts.conf
中有以下配置
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/history"
ServerName history.test.in
<Directory "C:/xampp/htdocs/history">
Options All
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
此外,我在 apache\conf\httpd.conf 文件中启用了此功能,
Include conf/extra/httpd-vhosts.conf
在drivers\etc\hosts文件中,我有
127.0.0.1 localhost
127.0.0.1 history.test.in
当我尝试访问 http://history.test.in, site is not loading but when tried with http://localhost/history 时,它起作用了。我做错了什么吗?另外,我在 Apache 中没有看到任何错误日志。
以上配置正确。虚拟主机不工作的原因是由于防火墙阻止、杀毒软件中断、系统中多个OS环境等不正确的设置。
这个post(大开眼界)帮我在windowsxampp环境中找到了问题:https://serverfault.com/questions/452268/hosts-file-ignored-how-to-troubleshoot
特别是ipconfig /displaydns DNS命令帮我发现新主机正确生效
此外,如果您的系统中有 运行 多个版本的 OS(windows 7、vista 或 windows 10),请确保编辑 运行 drivers\etc\hosts OS 的主机文件而不是空闲的。
我在 extra\httpd-vhosts.conf
中有以下配置NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/history"
ServerName history.test.in
<Directory "C:/xampp/htdocs/history">
Options All
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
此外,我在 apache\conf\httpd.conf 文件中启用了此功能,
Include conf/extra/httpd-vhosts.conf
在drivers\etc\hosts文件中,我有
127.0.0.1 localhost
127.0.0.1 history.test.in
当我尝试访问 http://history.test.in, site is not loading but when tried with http://localhost/history 时,它起作用了。我做错了什么吗?另外,我在 Apache 中没有看到任何错误日志。
以上配置正确。虚拟主机不工作的原因是由于防火墙阻止、杀毒软件中断、系统中多个OS环境等不正确的设置。
这个post(大开眼界)帮我在windowsxampp环境中找到了问题:https://serverfault.com/questions/452268/hosts-file-ignored-how-to-troubleshoot 特别是ipconfig /displaydns DNS命令帮我发现新主机正确生效
此外,如果您的系统中有 运行 多个版本的 OS(windows 7、vista 或 windows 10),请确保编辑 运行 drivers\etc\hosts OS 的主机文件而不是空闲的。