Is it possible to use variables in httpd.conf

前端 未结 2 1517
谎友^
谎友^ 2021-02-05 01:46

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 myva         


        
2条回答
  •  既然无缘
    2021-02-05 02:33

    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: https://stackoverflow.com/a/15731921/498798

提交回复
热议问题