【发布时间】:2012-03-16 00:48:43
【问题描述】:
不要认为我的虚拟主机工作正常。这就是我在 httpd.conf 中的内容......这是文件中的最后一件事:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/testing
ServerName testing.aa.local
</VirtualHost>
在我的 /etc/hosts 文件中:
127.0.0.1 testing.aa.local
现在,当我转到 testing.aa.local 时,它会显示站点根目录的索引页面。在 httpd.conf 中,文档根是DocumentRoot /var/www/html。看来它正在使用该文档根目录而不是 VirtualHost 文档根目录。当我重新启动 httpd 时没有错误。当我说 httpd -S 它说:
$ sudo /usr/sbin/httpd -S
VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers:
_default_:443 aa.local (/etc/httpd/conf.d/ssl.conf:81)
*:* aa.local (/etc/httpd/conf/httpd.conf:974)
*:80 is a NameVirtualHost
default server testing.aa.local (/etc/httpd/conf/httpd.conf:1031)
port 80 namevhost testing.aa.local (/etc/httpd/conf/httpd.conf:1031) Syntax OK
任何人都明白为什么当我去 testing.aa.local 时它显示的是 /var/www/html 的索引页面而不是 /var/www/html/testing?同样,/var/www/html 被定义为 httpd.conf 文件作为 DocumentRoot 但后来我声明了虚拟主机容器,所以我认为它应该覆盖它?
【问题讨论】: