Webmasters Stack Exchange is a question and answer site for pro webmasters. 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 have a single server that I use to host a whole bunch of smallish websites. It's recently come to my attention that a service called LetsEncrypt allows me to get an SSL certificate for free. The catch, as far as I can tell, is that they don't allow you to do any traditional SSL setup and instead you must use a script they provide which automatically requests a certificate for your server and configures apache for it. The problem, now, is that their setup script does not support the fact that I have 8+ virtual hosts all in my single 000-default.conf file for apache.

So my question is, how do I configure apache to read multiple site configuration files so that I can separate my different virtual host definitions into different files?

share|improve this question
up vote 4 down vote accepted

You can use the Include directive to include other config files and split up your main config.

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

You can also use wildcards, so you can have each virtual host in a separate config file and include all without having to modify your main config file:

Include conf/extra/vhosts/*.conf

Reference:
https://httpd.apache.org/docs/2.4/mod/core.html#include

share|improve this answer
1  
I was going to say that, but you beat me to it. lol – Mike Mar 1 at 17:45
1  
Thanks! I think this is exactly what I needed. – Pecon Mar 1 at 17:45
    
I am a fan of the ole' sites-available with separate confs per site. You can still use a wildcard like in your example. This directory should already exist with a 000-default.conf in most installs. Either way, the same thing. – closetnoc Mar 2 at 0:36

Your Answer

 
discard

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.