What is the right way to set a global environment variable, such that it is picked up all processes, including those started via init.d (service <service> start), on Ubuntu? Details:

I first saw this issue with PHP, but now see it is not PHP specific. Follows is the original explanation of what I am seeing.

In the /etc/environment I have set:


Then in the PHP configuration file /etc/php/7.2/fpm/pool.d/www.conf I have defined:


And then restarted php7.2-fpm. Then upon checking in the phpinfo page, the variable is listed, but not not with its value. It is defined and accessible in login shells.

I did try setting clear_env = no in the www.conf file, but that doesn't make the value available.

I am launching php7.2-fpm via service php7.2-fpm start, not as a child of my login shell.

What should I be doing to ensure an environment is available to all processes?

My Web server is Nginx and the OS environment is Ubuntu 18.04.1 LTS.


It might be this: http://nginx.org/en/docs/ngx_core_module.html#env

By default, nginx removes all environment variables inherited from its parent process except the TZ variable.

You can use the env directive to explicitly allow nginx to pick up environment variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.