简体   繁体   English

Windows 10和Apache 2.4上的虚拟主机

[英]Virtual host on Windows 10 with Apache 2.4

Can you tell me please what am I doing wrong in Virtual host settings? 您能告诉我虚拟主机设置在做什么错吗? I am editing two files: Apache/conf/extra/httpd-vhosts.conf and Windows/System32/drivers/etc/hosts 我正在编辑两个文件:Apache / conf / extra / httpd-vhosts.conf和Windows / System32 / drivers / etc / hosts

httpd-vhosts.conf looks like httpd-vhosts.conf看起来像

<VirtualHost 127.0.0.1>
   ServerName scouttautomotive.com
   ServerAlias www.scouttautomotive.com
   DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>

<VirtualHost 127.0.0.1>
   ServerName bosp.sk
   ServerAlias bosp.sk.localhost
   DocumentRoot "C:/Apache24/htdocs/bosp/web"
</VirtualHost>

hosts file looks like 主机文件看起来像

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

127.0.0.1 scouttautomotive.com
127.0.0.1 bosp.sk

What is wrong with it? 怎么了 I am realy confused cause bosp.sk virtual host works well. 我真的很困惑,因为bosp.sk虚拟主机运行良好。

After setting the domain ip to 127.0.0.1 to host file, You must restart your computer or flush dns cache to get that applied. 将域ip设置为127.0.0.1作为主机文件后,必须重新启动计算机或刷新dns缓存才能应用该文件。 Did you do? 你做了吗

So look at these config files and note that difference is only in the last letter of ServerName. 因此,请查看这些配置文件并注意,区别仅在于ServerName的最后一个字母。

httpd-vhosts.conf httpd-vhosts.conf

<VirtualHost 127.0.0.1>
   ServerName scouttautomotive.com
   ServerAlias scout.com.localhost
   DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>

<VirtualHost 127.0.0.1>
   ServerName scouttautomotiv.com
   ServerAlias drom.com.localhost
   DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>

hosts 主机

127.0.0.1 scouttautomotive.com
127.0.0.1 scouttautomotiv.com

First version redirects me to one hosting which offers this domain to sell. 第一个版本将我重定向到一个提供此域名出售的主机。 Second version works well as virtual host. 第二版可以很好地用作虚拟主机。 Both are created in the same time. 两者是在同一时间创建的。 So it looks command ipconfig /flushdns may not be enough. 因此,看起来命令ipconfig / flushdns可能还不够。

Another possible solutions can be find here https://serverfault.com/questions/452268/hosts-file-ignored-how-to-troubleshoot Good luck! 另一种可能的解决方案可以在这里找到https://serverfault.com/questions/452268/hosts-file-ignored-how-to-to-roubleshoot祝您好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM