blob: 668f44e06c73c693ea5a029524aa317dbe960d88 [file]
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<modulesynopsis metafile="mod_env.xml.meta">
<name>mod_env</name>
<description>Modifies the environment which is passed to CGI scripts and
SSI pages</description>
<status>Base</status>
<sourcefile>mod_env.c</sourcefile>
<identifier>env_module</identifier>
<summary>
<p>This module allows for control of internal environment variables that
are used by various Apache HTTP Server modules. These variables are also
provided to CGI scripts as native system environment variables, and available
for use in SSI pages. Environment variables may be passed from the shell
which invoked the <program>httpd</program> process. Alternatively,
environment variables may be set or unset within the configuration process.</p>
</summary>
<seealso><a href="../env.html">Environment Variables</a></seealso>
<seealso><directive module="mod_setenvif">SetEnvIf</directive></seealso>
<directivesynopsis>
<name>PassEnv</name>
<description>Passes environment variables from the shell</description>
<syntax>PassEnv <var>env-variable</var> [<var>env-variable</var>]
...</syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>FileInfo</override>
<usage>
<p>Specifies one or more native system environment variables to make available
as internal environment variables, which are available to Apache HTTP Server modules
as well as propagated to CGI scripts and SSI pages. Values come from the
native OS environment of the shell which invoked the
<program>httpd</program> process.</p>
<example><title>Example</title>
<highlight language="config">
PassEnv LD_LIBRARY_PATH
</highlight>
</example>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>SetEnv</name>
<description>Sets environment variables</description>
<syntax>SetEnv <var>env-variable</var> [<var>value</var>]</syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>FileInfo</override>
<usage>
<p>Sets an internal environment variable, which is then available to Apache
HTTP Server modules, and passed on to CGI scripts and SSI pages.</p>
<example><title>Example</title>
<highlight language="config">
SetEnv SPECIAL_PATH /foo/bin
</highlight>
</example>
<p> If you omit the <var>value</var> argument, the variable is set to
an empty string.</p>
<note><p>The internal environment variables set by this directive are set
<em>after</em> most early request processing directives are run, such as access
control and URI-to-filename mapping. If the environment variable you're
setting is meant as input into this early phase of processing such as the
<directive module="mod_rewrite">RewriteRule</directive> directive, you should
instead set the environment variable with
<directive module="mod_setenvif">SetEnvIf</directive>.</p>
</note>
</usage>
<seealso><a href="../env.html">Environment Variables</a></seealso>
</directivesynopsis>
<directivesynopsis>
<name>UnsetEnv</name>
<description>Removes variables from the environment</description>
<syntax>UnsetEnv <var>env-variable</var> [<var>env-variable</var>]
...</syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<override>FileInfo</override>
<usage>
<p>Removes one or more internal environment variables from those passed
on to CGI scripts and SSI pages.</p>
<example><title>Example</title>
<highlight language="config">
UnsetEnv LD_LIBRARY_PATH
</highlight>
</example>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>SetEnvFromFile</name>
<description>Sets environment variables from a file</description>
<syntax>SetEnvFromFile <var>file-path</var></syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context></contextlist>
<compatibility>Available in version 2.5.1 and later.</compatibility>
<usage>
<p>Sets internal environment variables read from a file, which are then
available to Apache HTTP Server modules, and passed on to CGI scripts and
SSI pages. This is equivalent to a series of <directive
module="mod_env">SetEnv</directive> directives, one per variable, but keeps
the values in a separate file.</p>
<p>The <var>file-path</var> is either an absolute path or a path relative
to the <directive module="core">ServerRoot</directive>. The file is read
once when the configuration is parsed; changes to it take effect only after
the server is restarted.</p>
<p>Each line of the file has the form <code>name=value</code>. Blank lines
and lines beginning with <code>#</code> are ignored, and leading and
trailing whitespace is stripped. If a line contains no <code>=</code>, the
variable is set to an empty string. A line ending in a backslash
(<code>\</code>) is continued on the following line, just as in the main
configuration files.</p>
<example><title>Example</title>
<highlight language="config">
SetEnvFromFile conf/app.env
</highlight>
</example>
<example><title>Example file (<code>conf/app.env</code>)</title>
<highlight language="config">
# Application settings
APP_MODE=production
SPECIAL_PATH=/foo/bin
</highlight>
</example>
<note><p>As with <directive module="mod_env">SetEnv</directive>, the
variables are set <em>after</em> most early request processing directives
are run, such as access control and URI-to-filename mapping.</p>
</note>
<note type="warning"><title>Security</title>
<p>Unlike <directive module="mod_env">SetEnv</directive>, this directive
reads the <em>contents</em> of a file into the internal environment, where
they may be exposed through CGI, SSI, logging and other consumers. To
prevent an untrusted author from disclosing the contents of any file
readable by the server (for example configuration or credential files
elsewhere on the host), <directive>SetEnvFromFile</directive> is
<strong>not</strong> permitted in <code>.htaccess</code> files; it may only
be used in the main server configuration.</p>
</note>
</usage>
<seealso><a href="../env.html">Environment Variables</a></seealso>
<seealso><directive module="mod_env">SetEnv</directive></seealso>
</directivesynopsis>
</modulesynopsis>