apache - 如何基于环境变量在 Apache 配置中包含外部 httpd.conf

标签 apache httpd.conf

我想根据外部设置的环境变量在我的主 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/

相关文章:

php - 在 CentOS7 中无法访问 Apache 上的 URL 链接

python - Django/Apache 错误 "attempt to write a readonly database"

mysql - xampp 连接到工作 WIFI 后停止工作

web - 在 CentOS 中更改 apache2 httpd 的 RootDirectory

apache - 安装 OS X El Capitan 后,Apache 无法正常工作

apache - 如何更改在 DOCKER 容器内运行的 apache 的 httpd.conf 并重新启动 apache

django - mod_wsgi (3.4-14)/Apache 2.4.12/Red Hat (6.7)/Django 1.8.2 卡在负载下

apache - 在 Docker 容器上启动 Apache

php - UTF-8贯穿始终

macOS Sierra 10.12.3 上的 PHP 7.1 - 由 Homebrew 安装