几个虚拟主机之间共享配置 [英] Sharing configuration between several VHosts

查看:137
本文介绍了几个虚拟主机之间共享配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我管理的httpd安装与其上运行多个站点,每个站点内它自己定义的<虚拟主机> 指令。有几个配置变量(其中大部分来自核心以及一些的php_flag / php_value ),它是完全一样的几个定义的网站。

I'm managing a httpd installation with several sites running on it, each defined within it's own <VirtualHost> directive. There are several configuration variables (most of them from core as well as some php_flag/php_value) that are exactly the same for several of the sites defined.

我想能够定义将应用于多个配置集&LT;虚拟主机&GT; 同时指令(去除冗余,使服务器维护稍微容易一些)。

I would like to be able to define a configuration set that will apply to several <VirtualHost> directives at the same time (to remove redundancy and make the server maintenance a little bit easier).

我已经使用其认为&LT;目录&GT; ,但是很多我需要设置配置值,不能从内部&LT修改;目录&GT ; 。我也试图定义另一个&LT;虚拟主机&GT; 部分,包含所有的网站,我想分享在

I have considered using <Directory>, however many of the configuration values I need to set, cannot be modified from within <Directory>. I have also tried to define another <VirtualHost> section, containing all of the sites I want to share the config in

<VirtualHost xx.xx.xx.xx:80 yy.yy.yy.yy:80>
    ...config...
</VirtualHost>

但这只是导致

VirtualHost xx.xx.xx.xx:80 overlaps with VirtualHost yy.yy.yy.yy:80, the first has precedence, perhaps you need a NameVirtualHost directive

任何想法,我怎么能做到这一点?

Any idea how I can achieve this?

推荐答案

在Apache文档,这就是所谓的大规模虚拟主机配置

In apache documentation this is called mass VirtualHost configuration.

几种解决方案存在:


  • mod_vhost_alias ,用 VirtualDocumentRoot 指令,但它通常是过于简单和管理比的DocumentRoot 和域名都挺难的。

  • 先进的mod_rewrite技巧,因为mod_rewrite的是瑞士小刀能做的一切,但一切似乎当它与mod_rewrite的。做得相当复杂

  • mod_macro 是一个模块,允许宏无限列表的使用与可以Virtualhosts(例如)之间重复使用的参数,这样你就可以比的DocumentRoot 添加更多的参数和服务器名称和共享虚拟主机薮猫之间的单配置文件。

  • mod_vhost_alias, with the VirtualDocumentRoot instructions, but it is usually too simple and managing other variations than DocumentRoot and the domain name are quite hard.
  • advanced mod_rewrite tricks, as mod_rewrite is a swiss knife and can do everything, but everything seems quite complex when it is done with mod_rewrite.
  • mod_macro is a module that allow the usage of an infinite list of macros with parameters that can be reused between Virtualhosts (for example), so you can add more parameters than DocumentRoot and ServerName and share single configurations files between serval Vhosts.

这篇关于几个虚拟主机之间共享配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆