Apache Web 服务器虚拟主机

Apache Web 服务器虚拟主机

我正在用两个虚拟主机搭建一个 apache web 服务器,在我的另一个 centos 6 最小虚拟机上有一个仅缓存的 DNS 服务器,我的 Apache 服务器的 IP 地址是 192.168.1.9,当我尝试在我的测试虚拟机 Windows XP 上浏览该 IP 地址(192.168.1.9/index.html)时,它显示“index.html”的内容,但是当我尝试使用域名浏览时,“http://domain1.com“,”连接已超时“。当我尝试使用我的“domain2.com”时,结果相同,只是当我浏览“192.168.1.9/index2.html”时,它不显示我的domain2文件的内容。

<VirtualHost *:80>
DocumentRoot /home/demo/public_html/domain1.com/public
ServerName domain1.com
ServerAlias www.domain1.com
ErrorLog /home/demo/public_html/domain1.com/log/error.log
CustomLog /home/demo/public_html/domain1.com/log/access.log common
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/demo/public_html/domain2.com/public
ServerName domain2.com
ServerAlias www.domain2.com
ErrorLog /home/demo/public_html/domain2.com/log/error.log
CustomLog /home/demo/public_html/domain2.com/log/access.log common
</VirtualHost>

这和 DNS 服务器记录、区域文件、CNAME 有什么关系吗?我对这些东西不太了解,我对这类东西很陌生。谢谢

答案1

对于本地(没有全局 DNS 条目)网站,使用HOSTS 文件将 domain1.com 和 domain2.com 转换为 192.168.1.9。

相关内容