Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We store VirtualHost entries in (dev|staging|live).conf files within the SVN repository for the site.

For example:


It'd be handy to be able to include them automatically, such as: Include /var/www/vhosts/*/live.conf

But that doesn't seem to work.

We've worked around it with a simple PHP script:

$vhosts = '';
foreach (glob('/var/www/vhosts/*/vhost/dev.conf') as $filename) {
    $vhosts .= "\nInclude $filename";

file_put_contents('/var/www/vhosts/vhosts.conf', $vhosts);

However, I'd love to simplify and get Apache (2.2.3) to do the job without requiring the PHP step.


share|improve this question

apache2 does not support wildcards in includes. However, you could arrange it a bit in the following manner:

  • create some directory for your configs (such as /etc/apache2/myconfigs)
  • symlink your configuration dynamically to apache2:
rm -f /etc/apache2/myconfigs/*
for i in $(find /var/www/vhosts/*/live.conf); do \
tempfn=$(echo $i|cut -d/ -f5-6|sed s,/,_,);  \
ln -s $i /etc/apache2/myconfigs/$tempfn.conf \
  • add a "Include /etc/apache2/myconfigs" in your apache2.conf

Note: on cut, i used -f5-6 for delimiter joining (to provide something like site1.com_live.conf symlink name), but you might have to adjust that according to your own fs path. Note on note: the above is for bash, might need adapting for other shells.

share|improve this answer

I've tested, it through the below error when checking syntax:

httpd: Syntax error on line 211 of /etc/httpd/conf/httpd.conf: Wildcard patterns not allowed in Include /etc/httpd/*/pr.conf

According to the documentation, from version 2.0.41, it supports the wildcard matching follow shell-style (fnmatch()). But it seems that it only works with the file (or the last component in the path), not the directory.

Testing with python, it returns true:

In [1]: import fnmatch

In [2]: fnmatch.fn
fnmatch.fnmatch      fnmatch.fnmatchcase  

In [2]: fnmatch.fnmatch('/etc/httpd/','/etc/httpd/*/live.conf')
Out[2]: True
share|improve this answer
According to my apache 2.2.19: apache2: Syntax error on line 229 of /etc/apache2/apache2.conf: Wildcard patterns not allowed in Include /etc/apache2/conftest/*/a.conf – O G Aug 16 '11 at 14:29
My 2.2.12 on Ubuntu and 2.2.3 on CentOS 5 gives me Wildcard patterns not allowed in Include – Iain Aug 16 '11 at 14:36
It looks like wildcards are only allowed in the last component of the path. – quanta Aug 16 '11 at 15:01

mod_perl allows for the following construct:

    foreach $file (glob '/etc/httpd/conf.d/vhosts/*/live.conf') {
        push @Include, $file;

This can be used in place of the Include directive.

share|improve this answer

I have had this problem for a while and have written a blog post on how to fix it by applying some patches to apache, I hope it helps. I works for me :)

share|improve this answer

Your Answer


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.