I have tried and researched a way to set the php_admin_value based on a lookup table or a environment variable (set by SetEnvIf
) and setting the variable with php_value, but found nothing that would probably suit you (having all configuration in one VirtualHost
).
As a last resort I could advice you to a devious plan, hiding some code...
With the php configuration directive auto_prepend_file
you could execute some code before actually starting a script. There you can do a lookup based on the virtual host, or use a variable set by SetEnvIf
.
Apache VirtualHost config:
SetEnvIfNoCase Host "^sandbox.coolhaven.info$" TZ=Europe/Moscow
SetEnvIfNoCase Host "^sandbox2.coolhaven.info$" TZ=Europe/Paris
php_value auto_prepend_file /var/www/misc/timezone_injector.php
/var/www/misc/timezone_injector.php
<?php date_default_timezone_set($_ENV["TZ"]);
Of course, the SetEnvIf
statements could be moved to a switch statement in your php code.
Your application developer could suspect something happened before their code because the timezone_injector.php
will show up in stack traces. But this could be a solution if you have a obfuscated or strict licensed PHP applications you are not able to touch due to non technical reasons.