本文介绍了虚拟主机 DocumentRoot 未更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不要认为我的虚拟主机工作正常.这是我在 httpd.conf 中的内容...这是文件中的最后一件事:

Don't think my virtualhost is working correctly. This is what I have inside of httpd.conf...it is the last thing in the file:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/testing
ServerName testing.aa.local
</VirtualHost>

在我的/etc/hosts 文件中:

In my /etc/hosts file:

127.0.0.1 testing.aa.local

现在,当我转到 testing.aa.local 时,它会显示站点根目录的索引页面.在 httpd.conf 中,文档根目录是 DocumentRoot/var/www/html.看起来它正在使用该文档根目录而不是 VirtualHost 文档根目录.当我重新启动 httpd 时,没有错误.当我说 httpd -S 时,它说:

Now when I go to testing.aa.local it shows the index page of the root of the site. In httpd.conf the document root is DocumentRoot /var/www/html. It appears it is taking that document root and not the VirtualHost documentroot. When I restart httpd there are no errors. When I say httpd -S it says:

$ 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 但后来我声明了虚拟主机容器,所以我认为它应该覆盖它?

Anyone understand why when I go to testing.aa.local it is showing me the index page of /var/www/html rather than /var/www/html/testing? Again, /var/www/html is defined as the httpd.conf file as the DocumentRoot but later on I declare the virtualhost container and so I thought it should overwrite it?

推荐答案

在我的 httpd.conf 文件中有一个虚拟主机容器已经准备好了.我已将其注释掉,现在可以使用了.

In my httpd.conf file there are a virtualhost container all ready. I commented it out and it now works.

这篇关于虚拟主机 DocumentRoot 未更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 22:00