shell environment variables in "include"-directive not working
Maxim Dounin
mdounin at mdounin.ru
Thu May 13 04:29:29 MSD 2010
Hello!
On Thu, May 13, 2010 at 12:49:21AM +0200, Markus Grobelin wrote:
> Hy everybody,
> i'm doing my first steps with nginx/0.8.36 and trying to get *NIX
> shell environment variables working inside the configuration files.
> Sadly, it's seems they aren't working inside the
> "include"-directive! :(
nginx doesn't have syntax for expanding environment variables in
configuration file. Syntax $var used for runtime per-request
variables (supported by some directives, support explicitly noted
in directive descriptions).
[...]
> The [emerg] indicates, that the $INSTANCE environment variable isn't
> expanded, whereas the "user" and "pid" directive doesn't raise an
> exception??
Because there is no syntax error in user "$USER" and config parser
has nothing against it. As you aren't running as root nginx
just prints warning about being non-root and forgets about it.
Under root you should see:
[emerg]: getpwnam("$USER") failed in /path/to/nginx.conf:line
(unless you actually have "$USER" in your /etc/passwd)
Similar thing with pid. It's syntactically correct and will only
produce error when nginx will try to create pid file. If you
happen to cleanup other critical config errors you should see
something like this on startup:
[emerg]: open() "/nginx/$INSTANCE/run/nginx.pid" failed (2: No such file or directory)
(again, unless you actually have "/nginx/$INSTANCE/run/" directory)
Maxim Dounin
More information about the nginx
mailing list