Apache:对多个虚拟主机使用相同的Directory指令

这是一个示例VirtualHost条目

<VirtualHost *:80> ServerName domain.com ErrorLog logs/domain.com-error_log CustomLog logs/domain.com-access_log common DocumentRoot "/var/www/srs/web" DirectoryIndex index.php Alias /sf /usr/share/pear/data/symfony/web/sf <Directory "/usr/share/pear/data/symfony/web/sf"> AllowOverride All Allow from All </Directory> <Directory "/var/www/srs/web"> AllowOverride All Allow from All </Directory> </VirtualHost> 

现在,我有6个其他的领域来设置这种方式。 他们都将共享一个DcoumentRoot,所以我需要设置唯一的每个域都是唯一的ServerName和* Log值。 由于我对这类东西大部分都是复制贴图,所以我准备做的只是复制这个块6次,然后改变我需要的位。

那么,我能否至less拿出号码簿条目并以某种方式使其全球化?

拉你的目录节在你的VirtualHost容器之外,它应该做你想做的。

 <VirtualHost *:80> ServerName domain.com ErrorLog logs/domain.com-error_log CustomLog logs/domain.com-access_log common DocumentRoot "/var/www/srs/web" DirectoryIndex index.php Alias /sf /usr/share/pear/data/symfony/web/sf </VirtualHost> <VirtualHost *:80> ServerName domain2.com ErrorLog logs/domain2.com-error_log CustomLog logs/domain2.com-access_log common DocumentRoot "/var/www/srs/web" DirectoryIndex index.php Alias /sf /usr/share/pear/data/symfony/web/sf </VirtualHost> <Directory "/usr/share/pear/data/symfony/web/sf"> AllowOverride All Allow from All </Directory> <Directory "/var/www/srs/web"> AllowOverride All Allow from All </Directory>