My .htaccess:
SetEnv tvar "my value"
RewriteEngine on
RewriteRule .* - [E=boostpath:normal]
My virtual host settings:
AllowOverride All
Options FollowSymLinks
Require all granted
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9001/home/dir/public_html/www.site.com/$1
My php file:
<?php
putenv("foo=bar");
echo "<br><br>env";
echo getenv("foo"); #works, outputs bar
echo "<br><br>env2";
echo getenv("tvar"); #doesn't work, empty
echo getenv("REDIRECT_tvar"); #doesn't work, empty
echo "<br><br>";
echo "<br><br>env3";
echo getenv("boostpath"); #doesn't work, empty
echo getenv("REDIRECT_boostpath"); #doesn't work, empty
echo "<br><br>";
print_r($_ENV) is also empty. But I tried turning variables_order = 'EGPCS' in php.ini and $_ENV shows up right but without any of the .htaccess set variables, and the result of the script is the exact same. Need this to work for a site to be able to cache both mobile and not mobile viewers in different directories.
Best Answer
In your VirtualHost directive:
Site is fast, drupal works, other files work, environment variables passed. DO NOT USE ProxyPass OR ProxyPassMatch!!!! It will not pass environment variables and break some php packages. Some have shown you can use LocationMatch and Interpolation but this seems to only work for ajp:// and not fcgi:// !!!
Unfortunately, this sets the user not to what is set in the php-fpm pool configuration but to the apache user and group. That is another question though so I will mark this resolved. I have to change writable folders to the apache user and group, which is sort of secure if you think about it, but it is also non sequitur and has some weird issues.