httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <rainer.j...@kippdata.de>
Subject Re: Environment confusion
Date Mon, 20 Oct 2008 18:49:32 GMT
Paul Querna schrieb:
> Graham Leggett wrote:
>> Hi all,
>>
>> I have just been picking apart the way that environment variables are
>> handled at config time within httpd, and there seems to be some
>> overloading on concepts that has caused some confusion.
>>
>> There are two environments within httpd, the first is the read only
>> system environment that is read using getenv(), the second is the
>> server->vars table that is read/write using mod_env and friends.
>>
>> A recent addition was made (it's on trunk and 2.2) that allows httpd
>> to include system variables in config directives, like this:
>>
>> DocumentRoot ${DOCUMENT_ROOT}
>>
>> The system environment variable DOCUMENT_ROOT is parsed and placed in
>> the config line, so far so good.
> 
> Actually the feature is just undocumented, and has existed since 2.0
> (maybe 1.3 too?)

No, not 1.3. For 1.3 there was a simple module mod_define which came as
contrib in the mod_ssl package. I ported mod_define to 2.0 and 2.2
because I found it still useful: you can't change real environment
variables during graceful or restart, because the parent process doesn't
get a new environment. mod_define allows to either get the vars from the
process environment or via variable defines inside the config files,
which can of course be changed and activated via restarts.

I once asked about any interest on mod_define (could be ASL) on this
list, but got the hint about the support of environment variables
starting with 2.0 as a response.

mod_define and mod_macro are somewhat orthogonal. mod_macro allows you
to reuse config templates with variable parametrization in the
configuration, mod_define allows you to use the same value in very
different places of the config, without putting it in every time (e.g.
path values etc.). Instead you use a variable and thus managing the
values gets easier. An Example is a setup, that separates the httpd
product directory (modules etc.) from the instance directory (conf etc.)
and var part (logs, run) without fixig everything in a build layout. You
prepend three variables like APACHE_HOME, APACHE_BASE and APACHE_VAR to
the respective pathes and set them once according to your needs.

If httpd internal envvars were usable in configs, then of course
mod_define would be superfluous.

Concerning mod_macro: VirtualHost elements do not work inside Macros. I
never investigated wha.

Regards,

Rainer

Mime
View raw message