Linux – How come I can’t see apache’s environment variables in the shell

apache-2.2apache-2.4debianlinux

I'm running apache on my Debian 8 laptop. I haven't made any config changes so everything is at the default.

apache2.conf uses environment variable defined in /etc/apache2/envvars, but when I open a shell on my laptop and run printenv I don't see any of those variables defined in envvars.

Are they running in a different context or something? Why can't I see them?

The apache docs regarding apache environment vars make no mention of envvars so I'm assuming the variables defined there are operating system env vars and are not an apache specific mechanism.

Best Answer

Are they running in a different context or something?

Yes.

Env vars are not global constants that apply to any process running on a machine. A file containing some env files isn't automatically loaded; Assuming apache uses the file, those env vars are only relevant to when apache is in use, i.e. a http context.

If you want them to be loaded in a shell you need to load them yourself, i.e.:

$ source /etc/apache2/envvars
$ env # show everything