Screen with bytes of info

RSS Feed
Technology Bytes

Splitting Apache Config into Pieces

Apache Include Directive

     For the websites that I run (Technology Bytes, Paasch Family Website, and Public Keyring), I use Apache HTTP Server.  It is one of the most used web servers around and it's open-source.

     I have been modifying and adding to it's configuration different directives for how I want my websites to display and how I want Apache to function.  Recently, I've noticed that my config file was getting very large and part of that is because I duplicate directives that I want to apply to several parts of the file.  There had been times when I would apply some directive or two to a part and then later forget to apply it to another area which resulted in unexpected results.  I started to think that there must be a better way to manage this so that I would only have to specify a directive in a common place and it would be applied to all the places that I wanted.

     I remembered that when I first set up SSL/TLS on my website, I included the httpd-ssl.conf file that comes with Apache in the "extra" directory.  So I decided to look up what the Include directive does and if it can be used to split apart the config file into manageable pieces.

     After looking up the directive on the Apache website and doing some testing, I found that the config file can be split up and that the Include directive can be used to import the pieces.  This allows the common directives to be specified in a separate config file and then whenever they are needed, an Include can be specified with the location of that common config file.