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.

2
  • 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.) Commented Jun 27, 2018 at 17:29
  • 1
    I did try SetEnvIf - same result. Commented Jun 27, 2018 at 22:50

1 Answer 1

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.