尽pipe未在“/ etc / hosts”中configuration,DNS服务器如何知道从httpd.conf获取ServerName

我只是没有得到如何我的浏览器能够路由到正确的path….当我给虚拟主机的ServerName ….即使它没有configuration在“/ etc / hosts”

请解释我…..

这是虚拟主机IAM在说话

<VirtualHost *:80> ServerName example.com ServerAlias example DocumentRoot "<*path*>" RailsEnv development <Directory "<*path*>" Order allow,deny Allow from all </Directory> </VirtualHost> 

DNS服务器不从httpd.conf中获取ServerName

您的浏览器不会路由请求,Web服务器将返回正确的页面部分基于浏览器发送的主机HTTP标头。

当您在浏览器中inputURL并按回车键时,名称将通过DNSparsing为IP,浏览器会向DNS查询返回的IP发送HTTP请求。

HTTP头形成了HTTP请求的核心。 其中之一是您在浏览器中input的主机或域名。

使用示例虚拟主机定义。

 <VirtualHost *:80> ServerName example.com DocumentRoot /var/www/example.com </VirtualHost> 

您的虚拟主机configuration中的ServerName指令与主机HTTP标头进行匹配。 所以,如果你input

 http://example.com 

Apache将收到请求并尝试匹配主机头

 Host: example.com 

与它的虚拟主机定义。 如果find一个匹配,就会使用任何列出的内容

 DocumentRoot 

在上面的例子中

 /var/www/example.com 

这可以是configuration中定义的索引文件,也可以是允许的目录索引。

http://en.wikipedia.org/wiki/Virtual_hosting#Name-based

我相信它实际上是从你的操作系统存储主机名,/ etc / hostname在Ubuntu或/ etc / sysconfig / network下的RHtypes发行版

在安装过程中,我想通过运行hostname命令来填充ServerName