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

I have a VPS server with CentOS with multiple domains (some I own, some I don't). I host my sites and my friends sites on it.

I have this structure:


So all my stuff is in my /var/www and my friends have their own username in the home folder. Every VirtualHost is in the httpd.conf and it's getting kinda big (I have over 50+ domains including sometimes sub-domains.

Will it be better to create a file in the sites-enabled for each domain I host like:


Is that a good practice? or what I did (using httpd.conf) is correct?

share|improve this question
up vote 1 down vote accepted

Here's an excellent link on how to:

basically you create each config file domain in:



<VirtualHost *:80>
  ServerAlias *
  ErrorLog /var/log/httpd/example.err
  CustomLog /var/log/httpd/example.log combined
  DocumentRoot /var/www/
  <Directory "/var/www/">
    Order allow,deny
    Allow from all

There might be times when it is desirable to disable a virtual host. Since the include in /etc/httpd/conf/httpd.conf specifies *.conf, it is possible to hide a virtual host by changing the configuration file name.

Disable a virtual host by adding a _ to the virtual host file name:

mv -v /etc/httpd/conf.d/example.conf{,_}

Enable a virtual host by removing the _ from the virtual host file name:

mv -v /etc/httpd/conf.d/example.conf{_,}


service httpd graceful
share|improve this answer
very interesting, thanks – rcs20 Feb 27 '12 at 14:21

It'll be much easier to manage all vhosts in their own separate configuration file. Here is what I would do (on Debian):

Place each vhost configuration in its own file inside /etc/apache2/sites-available/. Use a2ensite to create a symlink between the available vhost sites and the /etc/apache2/sites-enabled directory.

Then just add:

Include /etc/apache2/sites-enabled/

To httpd.conf

This way you can easily take sites offline, with a2dissite vhostname, for example: a2dissite

Since you have CentOS, the a2ensite script will not be present. Here's a way to simulate the Debian scripting methods:

share|improve this answer
why creating the conf to the sites-available and symlink to the sites-enabled? would it be easier to just create it in the sites-enabled? – rcs20 Feb 15 '12 at 22:13
By creating your configurations in sites-available and then symlinking them in sites-enabled, it allows you to disable sites without having to delete the configurations. There are other ways to achieve this, but this is the convention to do it this way. – Richard Holloway Feb 15 '12 at 22:22
This OP is using CentOS, not Debian or Ubuntu. – EEAA Feb 16 '12 at 0:04
@ErikA oh that make sense now thanks but can i keep the same logic separating the sites? and what can i do to enable / disable? – rcs20 Feb 16 '12 at 13:11
@rcs20 answer updated – Mathias R. Jessen Feb 16 '12 at 17:26

By default (at least in CentOS 6.2), Apache is configured to automatically include any configuration files located in the following directory:


Search your httpd.conf for the following line (add if it's not there):

Include conf.d/*.conf

Then just create config files for each virtual host:


And if you want to disable a virtual host, just rename:



share|improve this answer
On RHEL/CentOS at least, this is the RedHat-endorsed approach. In fact, doing things this way, it's exceedingly rare you'll ever have to edit httpd.conf, which is the whole point: you can do version upgrades and modify the server's mode of operation extensively by doing simple, naïve file manipulation à la that done by RPMs. The sites-available/sites-enabled approach is just another way to achieve the same goal. – BMDan Feb 26 '12 at 15:33

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.