【问题标题】:virtual hosts DocumentRoot not being changed虚拟主机 DocumentRoot 未更改
【发布时间】: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 但后来我声明了虚拟主机容器,所以我认为它应该覆盖它?

【问题讨论】:

    标签: apache dns


    【解决方案1】:

    在我的 httpd.conf 文件中有一个准备就绪的虚拟主机容器。我把它注释掉了,它现在可以工作了。

    【讨论】:

    • 恐怕我也无法从默认的“var/www/html”根文件夹中得到任何响应。就像我被卡住了。我也在 httpd.conf 中包含了 mod_jk.conf 来移动文档。更不用说我的新文档根目录了,默认的也显示找不到页面。
    猜你喜欢
    • 2013-05-07
    • 2016-01-22
    • 2012-10-26
    • 2018-05-04
    • 2013-12-31
    • 1970-01-01
    • 1970-01-01
    • 2019-05-01
    • 2011-10-11
    相关资源
    最近更新 更多