是否有可能使用变量在httpd.conf [英] Is it possible to use variables in httpd.conf

查看:118
本文介绍了是否有可能使用变量在httpd.conf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来的使用的某种在Apache httpd.conf文件的变量?我想定义一个值,并用它在整个块,如

 定义MYVAR somename #OR任何语法将
别名/我的/路径/一些/路径/ $ {MYVAR} #OR任何语法将


解决方案

是的,有点。你可以在与$ {ENVVAR}语法启动到配置文件取代环境变量。这是由你来弄清楚如何启动服务器之前设置这些变量。

http://httpd.apache.org/docs/2.2/configuring。 HTML#语法

请注意,这些变量将坚持像PHP语言中的任何脚本就能读取。

另外需要注意的是这些值是PTED一次跨$ P $仅在服务器启动时,使他们更像是不是变量常数是很重要的。

更新

由于httpd的2.4版本,看到这个答案,而不是: http://stackoverflow.com/a/15731921/498798

Is there a way to use variables of some sort in an apache httpd.conf file? I'd like to define a value and use it throughout a block, as in

define myvar somename #or whatever the syntax would be
alias /my/path "/some/path/${myvar} #or whatever the syntax would be

解决方案

Yes, kind of. You can get environment variables substituted in to the config file at start up with the ${ENVVAR} syntax. It's up to you to figure out how to set those variables before starting up the server.

http://httpd.apache.org/docs/2.2/configuring.html#syntax

Note that these variables will persist so any scripts in languages like php will be able to read them.

Also it's important to note that these values are interpreted once only when the server starts up so they're more like constants than variables.

Update

As of httpd version 2.4, see this answer instead: http://stackoverflow.com/a/15731921/498798

这篇关于是否有可能使用变量在httpd.conf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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