Chris Shaw
Chris Shaw

Reputation: 21

How to Dynamically Set Enviroment Variables in Apache2

On a test server, we use wildcards in the ServerAlias for dynamically generated sub domains.

Issue is i need to set a required custom environment called APP_HOME to be identical to the document_root.

<VirtualHost *:443>
    ServerName testserver.com
    ServerAlias *.testserver.com
    VirtualDocumentRoot = /var/www/branch/%1/
    SetEnv APP_HOME = /var/www/branch/%1/
</VirtualHost>

The expected result is for APP_HOME and DOCUMENT_ROOT to be the same, but currently

DOCUMENT_ROOT becomes /var/www/branch/testbranch/  

and

APP_HOME becomes /var/www/branch/%1/

Upvotes: 1

Views: 206

Answers (1)

Chris Shaw
Chris Shaw

Reputation: 21

This was never really resolved.

In the end we analysed the codebase and found that the custom enviroment variable was not needed and blanket replaced it with DOCUMENT_ROOT

One caveat was needing to ensure DOCUMENT_ROOT was set / passed in for cronjobs or cli operations.

Upvotes: 1

Related Questions