Global & user specific environment variables are not accessible through web request

  environment-variables, nginx, php, symfony

We trying to setup symfony project and drive the config from system environment variables.

We are using Ubuntu 18 with zsh, php-fpm7.4 and nginx.

While trying a bunch of things, I setup the variables in both places .zshrc and /etc/environment.


export DB_USER='<user>'
export DB_PASS='<pass>'
export DB_URL='<url>'

Same in /etc/environment, but without the export

Through the CLI the variables are accessible. However, on web request nothing is there.
So, I found at some point that nginx strips them out unless you define otherwise.

Added the following into nginx.conf:

env DB_USER;
env DB_PASS;
env DB_URL;

Same result.

How do I make sure that environment variables available in CLI and web request?

Source: Symfony Questions