1

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.

user2845840
  • 213
  • 1
  • 8
  • Have you tried `SetEnvIf` instead? `SetEnvIf` is processed early, `SetEnv` is processed late - I don't know whether that makes any difference in this instance? (By moving `SetEnv` to a VitualHost context it will effectively be processed earlier.) – MrWhite Jun 27 '18 at 17:29
  • 1
    I did try SetEnvIf - same result. – user2845840 Jun 27 '18 at 22:50

1 Answers1

1

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.

user2845840
  • 213
  • 1
  • 8