From: Joshua Slive
The most basic way to set an environment variable in Apache is
using the unconditional SetEnv
directive. Variables
-may also be passed from the environment when Apache is started
-using the PassEnv
directive.
PassEnv
directive.
+
+For additional flexibility, the directives provided by mod_setenvif
+allow environment variables to be set on a per-request basis,
+conditional on characteristics of particular requests. For example, a
+variable could be set only when a specific browser (User-Agent) is
+making a request, or only when a specific Referer [sic] header is
+found. Even more flexibility is available through the mod_rewrite's
+RewriteRule
which uses the [E=...]
option to
+set environment variables.
The directives provided by mod_setenvif allow environment variables
-to be set on a per-request basis based on characteristics of particular
-requests. For example, a variable could be set only when a specific
-browser (User-Agent) is making a request, or only when a specific
-Referer header is found. Even more flexibility is available through the
-mod_rewrite's RewriteRule
which uses the
-[E=...]
option to set environment variables.
Finally, mod_unique_id sets the environment variable
UNIQUE_ID
for each request to a value which is guaranteed
to be unique across "all" requests under very specific conditions.
In addition to all environment variables set within the Apache +configuration and passed from the shell, CGI scripts and SSI pages are +provided with a set of environment variables containing +meta-information about the request as required by the CGI specification.
+ +suexec.c
.One of the primary uses of environment variables is to communicate
-information to CGI scripts. In addition to all environment variables
-set within Apache, CGI scripts are provided with a set of
-meta-information about the request as provided for in the CGI specification. If you are using
-Suexec to execute CGI scripts under
-different userids, note that the environment will be cleaned down to a
-set of safe environment variables before the CGI script is
-executed. The set of safe environment variables is defined at
-compile time in suexec.c
.
+information to CGI scripts. As discussed above, the environment
+passed to CGI scripts includes standard meta-information about the request
+in addition to any variables set within the Apache configuration.
+For more details, see the CGI tutorial.
Server-parsed (SSI) documents processed by mod_include's
server-parsed
handler can print environment variables
using the echo
element, and can use environment variables
-in flow control elements.
+in flow control elements to makes parts of a page conditional on
+characteristics of a request. Apache also provides SSI pages with the
+standard CGI environment variables as discussed above. For more
+details, see the SSI tutorial.
Access to the server can be controlled based on the value of
environment variables using the allow from env=
and
deny from env=
directives. In combination with
@@ -124,6 +164,8 @@ can use these directives to deny access to a particular browser
(User-Agent).
Environment variables can be logged in the access log using the
LogFormat
option %e
. In addition, the
decision on whether or not to log requests can be made based on the
@@ -135,6 +177,8 @@ for filenames ending in gif
, or you can choose to only
log requests from clients which are outside your subnet.
The %{ENV:...}
form of TestString in the
RewriteCond
allows mod_rewrite's rewrite engine to make
decisions conditional on environment variables. Note that the
diff --git a/docs/manual/env.html.en b/docs/manual/env.html.en
index b32847fbbf..f436e32819 100644
--- a/docs/manual/env.html.en
+++ b/docs/manual/env.html.en
@@ -54,23 +54,60 @@ explains some of the ways to use environment variables in Apache.
The most basic way to set an environment variable in Apache is
using the unconditional SetEnv
directive. Variables
-may also be passed from the environment when Apache is started
-using the PassEnv
directive.
PassEnv
directive.
+
+For additional flexibility, the directives provided by mod_setenvif
+allow environment variables to be set on a per-request basis,
+conditional on characteristics of particular requests. For example, a
+variable could be set only when a specific browser (User-Agent) is
+making a request, or only when a specific Referer [sic] header is
+found. Even more flexibility is available through the mod_rewrite's
+RewriteRule
which uses the [E=...]
option to
+set environment variables.
The directives provided by mod_setenvif allow environment variables
-to be set on a per-request basis based on characteristics of particular
-requests. For example, a variable could be set only when a specific
-browser (User-Agent) is making a request, or only when a specific
-Referer header is found. Even more flexibility is available through the
-mod_rewrite's RewriteRule
which uses the
-[E=...]
option to set environment variables.
Finally, mod_unique_id sets the environment variable
UNIQUE_ID
for each request to a value which is guaranteed
to be unique across "all" requests under very specific conditions.
In addition to all environment variables set within the Apache +configuration and passed from the shell, CGI scripts and SSI pages are +provided with a set of environment variables containing +meta-information about the request as required by the CGI specification.
+ +suexec.c
.One of the primary uses of environment variables is to communicate
-information to CGI scripts. In addition to all environment variables
-set within Apache, CGI scripts are provided with a set of
-meta-information about the request as provided for in the CGI specification. If you are using
-Suexec to execute CGI scripts under
-different userids, note that the environment will be cleaned down to a
-set of safe environment variables before the CGI script is
-executed. The set of safe environment variables is defined at
-compile time in suexec.c
.
+information to CGI scripts. As discussed above, the environment
+passed to CGI scripts includes standard meta-information about the request
+in addition to any variables set within the Apache configuration.
+For more details, see the CGI tutorial.
Server-parsed (SSI) documents processed by mod_include's
server-parsed
handler can print environment variables
using the echo
element, and can use environment variables
-in flow control elements.
+in flow control elements to makes parts of a page conditional on
+characteristics of a request. Apache also provides SSI pages with the
+standard CGI environment variables as discussed above. For more
+details, see the SSI tutorial.
Access to the server can be controlled based on the value of
environment variables using the allow from env=
and
deny from env=
directives. In combination with
@@ -124,6 +164,8 @@ can use these directives to deny access to a particular browser
(User-Agent).
Environment variables can be logged in the access log using the
LogFormat
option %e
. In addition, the
decision on whether or not to log requests can be made based on the
@@ -135,6 +177,8 @@ for filenames ending in gif
, or you can choose to only
log requests from clients which are outside your subnet.
The %{ENV:...}
form of TestString in the
RewriteCond
allows mod_rewrite's rewrite engine to make
decisions conditional on environment variables. Note that the
diff --git a/docs/manual/mod/mod_env.html b/docs/manual/mod/mod_env.html
index bda93ec2db..3d6d610fe9 100644
--- a/docs/manual/mod/mod_env.html
+++ b/docs/manual/mod/mod_env.html
@@ -15,8 +15,8 @@
This module provides for -passing environment variables to CGI/SSI scripts.
+This module provides for modifying the environment which +is passed to CGI scripts and SSI pages.
This module allows Apache's CGI and SSI environment to inherit
-environment variables from the shell which invoked the httpd process.
-CERN web-servers are able to do this, so this module is especially
-useful to web-admins who wish to migrate from CERN to Apache without
-rewriting all their scripts This module allows for control of the environment that will be
+provided to CGI scripts and SSI pages. Environment variables may be
+passed from the shell which invoked the httpd process. Alternatively,
+environment variables may be set or unset within the configuration
+process. For additional information, we provide a document on
+Environment Variables in Apache.Summary
-
-Directives
@@ -81,7 +84,8 @@ rewriting all their scripts
Specifies one or more environment variables to pass to CGI scripts -from the server's own environment. Example: +and SSI pages from the environment of the shell which invoked +the httpd process. Example:
PassEnv LD_LIBRARY_PATH@@ -112,7 +116,7 @@ from the server's own environment. Example: Apache 1.1 and later.
Sets an environment variable, which is then passed on to CGI -scripts. Example: +scripts and SSI pages. Example:
SetEnv SPECIAL_PATH /foo/bin@@ -144,14 +148,11 @@ scripts. Example: Apache 1.1 and later.
Removes one or more environment variables from those passed on to -CGI scripts. Example: +CGI scripts and SSI pages. Example:
UnsetEnv LD_LIBRARY_PATH- - -