Setting Environment Variables


SetEnv foo bar UnSetEnv foo PassEnv foo


Environment variables are variables that can be shared between modules and that are also available to external processes such as CGIs and server side include (SSI) documents. Environment variables also can be used for intermodule communication and to flag certain requests for special processing.

You can set environment variables with the SetEnv directive. This variable will be available to CGI scripts and SSI pages, and can be logged or added to a header. For example

SetEnv foo bar


will create the environment variable foo and assign it the value bar.

Conversely, you can remove specific variables using the UnsetEnv directive.

Finally, the PassEnv directive enables you to expose variables from the server process environment. For example

PassEnv LD_LIBRARY_PATH


will make the environment variable LD_LIBRARY_PATH available to CGI scripts and SSI pages. This variable contains the path to loadable dynamic libraries in some Unix systems, such as Linux. You can get a listing of standard environment variables in the appendix.

Accessing an Environment Variable

You can access an environment variable named foo from an SSI page with

<!--#echo var="foo" -->


You can log its value with the %{foo}e formatting option, as explained in Chapter 3, or you can add it to an HTTP header, as explained in Chapter 10 with

RequestHeader set X-Foo "%{foo}e"






Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net