We store VirtualHost entries in (dev|staging|live).conf files within the SVN repository for the site.
For example:
/var/www/vhosts/site1.com/live.conf
/var/www/vhosts/site2.com/live.conf
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.
Possible?
Best Answer
apache2 does not support wildcards in includes. However, you could arrange it a bit in the following manner:
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.