Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

There are many virtual hosts in my apache configuration, each having quite a big amount of settings. The problem is that most of the virtual servers have the same settings. So config file is huge, full of identical virtual hosts, that differ only by ServerName directive. To change or add setting, I need to go through all of these vhosts.
Is it possible to somehow share settings between virtual hosts, but still having few of them with their own ones?
I hoped dynamic vhosts would be a good solution, but as I understand, it doesn't fit my problem, because there is no way to set specific settings for some of the vhosts. Furthermore I don't want my vhosts to be dynamic, because I have a fixed number of them. ServerAlias directive is also not a solution, because I need to know what url the user came from.

share|improve this question
up vote 0 down vote accepted

I have a similar situation to you and my solution was to write a (Perl) script that generates the vhost configs for me.

I have a configuration file which lists the few settings that are different per server (like ServerName, SSL certificate, etc) and then the Perl script combines the unique settings with generic ones and writes out many conf files in /etc/httpd/conf.d.

Then I include them all with something like this in the main config:

Include conf.d/*.conf

Every time I add a new vhost, I just add the data to the Perl script config file, run the script, then reload Apache.

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.