Here is how I set the variable within my Apaches VirtualHost Container
SetEnv MY_VAR "/opt/"
Now, PHP can perfectly access this vairable:
echo $_SERVER['MY_VAR'];
/opt/
However, if I call a shell script from my PHP code
passthru('/path/to/myscript');
MY_VAR is empty within /path/to/myscript.
If I however modify the call like this, it works:
passthru('export MY_VAR='. $_SERVER['MY_VAR'] .'; /path/to/myscript');
Is there a better way to pass all environment variables to the shell script? Since I need to pass multiple ones.
I also tried system(), exec(), backticks and shell_exec(). They all show the same behavior, as passthru().