Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here's a sample VirtualHost entry

<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>

Now, I have 6 other domains to setup this way. They will all share a single DcoumentRoot, so the only thing I need to setup that's unique per domain is the ServerName and *Log values. Since I'm mostly a copy-paster when it comes to this kind of stuff, what I'm prepared to do is just copy this block 6 times and change the bits I need to.

So, can I at least pull out the Directory entries and globalize them somehow?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Pull your Directory stanzas outside of your VirtualHost containers and it should do what you want.

<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>
share|improve this answer
    
Thanks, just what I was after! –  Peter Bailey Jul 8 '09 at 4:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.