我想根据外部设置的环境变量在我的主 Apache httpd.conf 中包含一个或另一个外部 httpd.conf 文件。
所以我想做这样的事情:
if $(DEV_ENV) == "main"<br/>
Include "first file"<br/>
if $(DEV_ENV) == "alt"<br/>
Include "second file"
我一直在研究 mod_setenv 模块,但它是用于在 Apache 配置中设置环境变量的。 如何使用环境变量并对其值进行比较?
最佳答案
抱歉,您无法对 Includes 执行这种动态逻辑。然而,Debian 版本当然允许通过替换模式直接引用环境变量,例如
Include conf/${APACHE_RUNTIME_TYPE}/*.conf
浏览“Apache2 envvars”以了解更多信息。
关于apache - 如何基于环境变量在 Apache 配置中包含外部 httpd.conf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6206520/