Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a large httpd.conf file, most of which is virtual hosts. Is there a way to make a file, say virtual_hosts.conf, and include it from httpd.conf? I've googled a bit, but can't seem to find much as far as includes, just module loading.

share|improve this question
    
Don't google for this. Read the Apache docs. –  Andrew Schulman Sep 26 '14 at 12:24
    
@AndrewSchulman: You know I asked this question over 3 years ago... right? –  Josh Sep 27 '14 at 3:01

3 Answers 3

up vote 11 down vote accepted

Information on apache httpd.conf files can be found at here.

Some snippets have been copied from this website to ensure that the information is not lost if the link would deprecated:

Include /usr/local/apache2/conf/ssl.conf
Include /usr/local/apache2/conf/vhosts/*.conf

Relative paths:

Include conf/ssl.conf
Include conf/vhosts/*.conf

Wildcards:

Include conf/vhosts/*/*.conf
share|improve this answer

You can do it with Include directive:

Include /path/to/virtual_hosts.conf
share|improve this answer

I separate each virtual host into it's own vhost config file, that way you don't wind up searching through a giant document looking for one little directive. Similar to Quanta's post:

Include /etc/apache2/vhosts.d/*.conf

Just place it as the last line in your httpd.conf

then just split your single vhosts.conf into individual files for each domain, i.e.

domain1.conf
domain2.conf
domain3.conf
etc.... 

much easier to manage. -sean

share|improve this answer

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.