如何基于环境变量在 Apache 配置中包含外部 httpd.conf
我想根据外部设置的环境变量在我的主 Apache httpd.conf 中包含一个或另一个外部 httpd.conf 文件。
所以我想做一些类似的事情:
如果 $(DEV_ENV) == "main"
包含“第一个文件”
如果 $(DEV_ENV) == "alt"
包含“第二个文件”
我一直在研究 mod_setenv 模块,但它是用于在 Apache 配置中设置环境变量的。 如何使用环境变量并对其值进行比较?
I'd like to include one or another external httpd.conf file in my main Apache httpd.conf based on an Environment Variable that is set externally.
So I would like to do something like:
if $(DEV_ENV) == "main"
Include "first file"
if $(DEV_ENV) == "alt"
Include "second file"
I've been looking at the mod_setenv module but that is for setting the environment variables within the Apache configuration.
How can I use the environment variables and do comparisons on its values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,您无法在 Includes 上执行这种动态逻辑。然而,Debian 版本当然允许通过替换模式直接引用环境变量,例如
浏览“Apache2 envvars”以了解更多信息。
Sorry but you can't do this sort of dynamic logic on Includes. However certainly the Debian version allows direct reference to environment variables through a substitution pattern, e.g.
Have a browse for "Apache2 envvars" to learn more.
看一下 ifdefine。这会评估命令行上传递的选项,而不是环境变量。以下符合您的要求:
Take a look at ifdefine. This evaluates options passed on the command line, rather than environment variables. The following matches your request: