如何在 apache 的 httpd.conf 文件中定义一个变量? [英] How to define a variable in apache's httpd.conf file?
问题描述
我想在 Apache 服务器的 httpd.conf
配置文件中定义一个变量.
I want to define a variable in Apache server's httpd.conf
configuration file.
例如:变量 static_path = C:\codebase\snp_static
Ex: variable static_path = C:\codebase\snp_static
我想在 httpd.conf
中需要的地方使用这个变量 (static_path).
and I want to use this variable (static_path) in httpd.conf
where ever required.
请告诉我如何在 httpd.conf
文件中定义一个变量?
Please tell me how can define a variable in httpd.conf
file ?
推荐答案
在 httpd.conf 中,声明您的变量:Define
(最好在第一行)
语法:Define
variable-name
variable-value
Within httpd.conf, declare your variable(s) with: Define
(Preferably at the very first line)
Syntax: Define
variable-name
variable-value
以这种方式:
#The line below creates the variable [static_path]
Define static_path C:/codebase/snp_static
您以后可以像这样使用这个变量:
ServerRoot = ${static_path}
...
DocumentRoot = ${static_path}
...
<Directory ${static_path}>
...etc.
您甚至可以组合多个变量:
#Below, I am going to combine variables [server_space] and [static_path]
Define server_space c:/
Define static_path codebase/snp_static
...
ServerRoot = ${server_space}${static_path}
...
DocumentRoot = ${server_space}${static_path}
...
<Directory ${server_space}${static_path}>
...etc.
文档:http://httpd.apache.org/docs/2.4/mod/core.html#define
这篇关于如何在 apache 的 httpd.conf 文件中定义一个变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!