tags:

views:

65

answers:

2
+1  A: 

If you want the environment variable to be passed to apache, you should make sure that said environment variable is defined for the environment that apache is running in. To do that, the easiest option is to add an export MYVAR=value line to envvars (should be located in /etc/apache2) or the script that starts apache (in /etc/init.d), and add your PassEnv MYVAR where it's wanted in your apache configuration.

Restarting apache should make sure the MYVAR environment variable is passed. AFAIK you won't be able to change the value of this var while apache is running though...

Some relevant info for CentOS : http://php.dzone.com/news/inserting-variable-headers-apa&default=false&zid=159&browser=16&mid=0&refresh=0

wimvds
A: 

You should access environment variables using the superglobal $_ENV:

$_ENV['MYVAR']

http://www.php.net/manual/en/reserved.variables.environment.php

Update

Your variable may actually be under $_SERVER afterall, as per the link below. Worth checking $_ENV though.

As per http://www.php.net/manual/en/reserved.variables.environment.php#97105

adam