在Apache HTTP Server 2.2版httpd.conf中包含文件


18

我有一个很大的httpd.conf文件,其中大多数是虚拟主机。有没有办法制作一个文件,例如virtual_hosts.conf,并从httpd.conf包含它?我已经用谷歌搜索了一下,但是似乎找不到包括头文件在内的内容,仅仅是模块加载。


1
不要为此谷歌。阅读Apache文档
Andrew Schulman 2014年

1
@AndrewSchulman:你知道我3年前问了这个问题吧?
2014年

Answers:


37

关于apache httpd.conf文件的信息可以在这里找到。

已从该网站复制了一些代码片段,以确保在不赞成使用该链接的情况下不会丢失信息:

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

相对路径:

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

通配符:

Include conf/vhosts/*/*.conf

8

我将每个虚拟主机分离到它自己的vhost配置文件中,这样您就不必在庞大的文档中寻找一个小指令了。与Quanta的帖子类似:

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

只需将其放在您的httpd.conf中的最后一行

然后只需将单个vhosts.conf拆分为每个域的单个文件,即

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

更容易管理。塞恩


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.