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

I currently just have one non-virtual host and my httpd.conf file is a regular run-of-the-mill file with ordinary modules and stuff. Now I have a need for another host yet it needs to be on the same server. I found apache virtual hosts and have a question about the setup of my config file.

Right now:

Listen 80
<IfModule> ........

My question is, to keep the same settings for each virtual host do I have to copy my current file twice? One inside each virtual host tag? Like this:

<VirtualHost *:80>
Listen 80
<IfModule> ............

<VirtualHost *:80>
Listen 80
<IfModule> .............

I hope I'm explaining myself correctly.

share|improve this question

No. Those httpd.conf settings are global context (Listen) and scope (LoadModule) and you do not duplicate them in VirtualHosts.

Note that it's a bit more complicated with what can and cannot be set in VHs, and what is inherited.

See for context.

share|improve this answer

As noted, most of your config file is global. You really just need to put in the virtual config, the bits that are different. There's really two key items:

The DocumentRoot, and ServerName. You might also have different log files, directory index, Aliases, etc. But the two key lines are as below.

    DocumentRoot /var/www/serverroot

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.