# About env directive

**URL:** <https://www.ruby-forum.com/t/about-env-directive/121304>\
**Category:** NGINX\
**Created:** [November 26, 2007, 6:05pm UTC](https://www.ruby-forum.com/t/about-env-directive/121304 "2007-11-26T18:05:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [November 26, 2007, 6:05pm UTC](https://www.ruby-forum.com/t/about-env-directive/121304/1 "2007-11-26T18:05:40Z")

</div>

Hi.

I want to enable the definition of custom environment variables in  
mod\_wsgi.

After a quick search in Nginx sources I have found the env directive and  
the ngx\_set\_environment function.

Unfortunately the documentation is in Russian only  
[Основная функциональность](http://sysoev.ru/nginx/docs/ngx_core_module.html#env).

I have found some problems with this directive.

- It seems that it is not possible to inherit enviroment variables  
from the “system”;  
only variables defined with env directive are added to os environment
- The syntax should be  
env VAR|VAR=VALUE,  
but, as an example,  
env MALLOC\_OPTIONS;  
does not put MALLOC\_OPTIONS in the environment.

Thanks Manlio P.

---

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [November 26, 2007, 6:10pm UTC](https://www.ruby-forum.com/t/about-env-directive/121304/2 "2007-11-26T18:10:55Z")

</div>

On Mon, Nov 26, 2007 at 05:49:28PM +0100, Manlio P. wrote:

> from the “system”;  
> only variables defined with env directive are added to os environment
> 
> - The syntax should be  
> env VAR|VAR=VALUE,  
> but, as an example,  
> env MALLOC\_OPTIONS;  
> does not put MALLOC\_OPTIONS in the environment.

“env VAR” inherits VAR from initial environment.  
However, some variables affects before nginx will remove from or add  
to new environment.

---

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [November 26, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/about-env-directive/121304/3 "2007-11-26T19:34:45Z")

</div>

Igor S. ha scritto:

> > I have found some problems with this directive.
> > 
> > - It seems that it is not possible to inherit enviroment variables  
> > from the “system”;  
> > only variables defined with env directive are added to os environment
> > - The syntax should be  
> > env VAR|VAR=VALUE,  
> > but, as an example,  
> > env MALLOC\_OPTIONS;  
> > does not put MALLOC\_OPTIONS in the environment.
> 
> “env VAR” inherits VAR from initial environment.

Ok, thanks.  
So it is not possible to inherits all vars from initial environment.

This seems reasonable, but I’m not sure that disabling implicit  
inheritance of vars from initial environment is always good.

> However, some variables affects before nginx will remove from or add  
> to new environment.

This should not be a problem.  
I call ngx\_set\_environment before Py\_Initialize.

Manlio P.
