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?

link|improve this question
feedback

1 Answer

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

Your Answer

 
or
required, but never shown

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