Top Nav

Apache Configuration Best Practices

There are numerous ways to organize your Apache configuration files. In some cases this organization will be dictated by your Linux distribution or control panel choice. When I’m working on RedHat/CentOS with no control panel here’s what I have found to be a good organization:

  • Minimize changes to /etc/httpd/conf/httpd.conf. It’s easier to upgrade or migrate if this file has few or not changes.
  • Place virtual host definitions in /etc/httpd/conf/vhosts.conf.
  • Put the document root for each website at /var/www/vhosts/[domain name]/httpdocs. Do not include “www” on the domain name. For example with “acme.com” the document root would be /var/www/vhosts/acme.com/httpdocs.
  • Here’s a template for the virtual host definition:

    Of course the SSL portion of the template is optional.