【问题标题】:Can I use an environment variable like hostname from the shell in httpd.conf?我可以在 httpd.conf 中使用 shell 中的主机名等环​​境变量吗?
【发布时间】:2011-05-26 05:06:12
【问题描述】:

我正在尝试让我的所有网络服务器将其日志写入共享存储系统。我想使用系统环境变量,这样我就不必维护 20 多个 httpd.conf 文件。我的 httpd.conf 文件是我部署的一部分,我们这样做是为了如果我们需要更改某些内容,所有主机都会得到该更改。

我想做的是这样的:

ErrorLog "|/usr/local/apache2/bin/rotatelogs /data/logs/apache/${hostname}_error_log.%Y-%m-%d 86400"

其中主机名与 shell 命令返回的内容相同,例如:

user@server1.domain@01:47:17:~ $> 主机名 server1.domain

【问题讨论】:

    标签: apache2 httpd.conf


    【解决方案1】:

    我注意到了,因为我使用的是 |通过rotatelogs 我应该试试$HOSTNAME 和whuduya 知道。

    ErrorLog "|/usr/local/apache2/bin/rotatelogs /data/logs/apache/$HOSTNAME.error_log.%Y-%m-%d 86400"

    效果很好:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-25
      • 1970-01-01
      相关资源
      最近更新 更多