为apache2虚拟主机使用不同的默认文档

我使用apache2在ubuntu 14服务器上设置了几个站点。 我复制000-default.conf并创build了一个site1.conf。 然后我改变了一些设置,重新加载apache2,现在几乎一切正常。 除了我在DirectoryIndex设置中的默认文档没有被遵守。 我的site1.conf看起来类似于这个:

<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName site1.com DocumentRoot /var/www/site1 ServerAlias *.site1.com DirectoryIndex one.php </VirtualHost> 

但我的问题是,访问http://site1.com/仍然显示index.html而不是one.php我想要显示。 请注意,一旦我得到这个工作,我想设置site2.com,并使用它的默认文件two.php。
我猜DirectoryIndex是一个在VirtualHost中不起作用的设置,而是在apache2.conf中的一个全局设置。 我search这些东西,找不到一个好的解释或办法。

不知道你是否需要one.php站点二或viseversa,但你可以随时做到:

 DirectoryIndex one.php two.php three.php 

一旦site1.com查找默认文件,它会看到one.php它将使用默认。 和其他site2.com不会findone.php,因为它会显示two.php?

但取决于什么是你的完整要求。

我猜DirectoryIndex是一个在VirtualHost中不起作用的设置,而是在apache2.conf中的一个全局设置。

没有必要猜测它在文档中

对于Apache 2.2 DirectoryIndex在VirtualHost上下文中是有效的,Apache 2.4 DirectoryIndex也是如此 。