We have PHP running via mod_fastcgi + suexec and it seems that PHP processes run this way don't see environment variables set via SetEnv
in a .htaccess
file. I checked via a perl script and a shell script (both run via mod_cgid
) that SetEnv indeed sets a variable (i.e. doing so is allowed by AllowOverride
and mod_env
is loaded). And I checked via $_SERVER
, $_ENV
, getenv()
, $HTTP_ENV_VARS
and phpinfo()
that PHP does not see the variable. I have not tried to find a proper solution, but I will post an answer that is a decent workaround.
1 Answer
For those who encounter the same problem, an inconvenient but quick workaround is to copy the relevant SetEnv
-lines from the .htaccess
files to the VirtualHost
configuration blocks of the corresponding domain and restart Apache. Variables set this way seem to be visible to PHP.
SetEnvIf
instead?SetEnvIf
is processed early,SetEnv
is processed late - I don't know whether that makes any difference in this instance? (By movingSetEnv
to a VitualHost context it will effectively be processed earlier.)