0

I have environment variables set in /etc/environment. printenv shows them. However, php-fpm isn't seeing them. I have uncommented clear_env = no in /etc/php-fpm.d/www.conf - this exposes SOME env vars to php-fpm (such as PATH), but none of those set in /etc/environment. Also, if I try to reference the /etc/environment environment variables in www.conf, like this: env[FOO] = $SOMEVAR (where SOMEVAR is set in /etc/environment), php has the envar FOO set to an empty value.

I'm by no means a Linux expert, but it seems to me that however php-fpm runs doesn't "use" the envars set in /etc/environment. Maybe? Please help.

Running Amazon Linux

THANKS! Adam

UPDATE:

sudo chkconfig --list php-fpm
php-fpm         0:off   1:off   2:on    3:on    4:on    5:on    6:off

Dan, does that help? This is how php-fpm starts on reboot. Thanks!

  • how is php-fpm started? – danblack Sep 28 '18 at 03:01
  • Why do you believe that php-fpm would ever read `/etc/environment`? – Michael Hampton Oct 02 '18 at 04:08
  • @MichaelHampton welp how/where else would I set environment variables that can be read by both php-fpm and php cli? – OakBehringer Oct 02 '18 at 04:46
  • AFAIK `/etc/environment` is a PAM-specific thing that applies only to user sessions when they log in. I've also never seen a system where anyone has actually tried to use it for anything... For your current problem I would use Amazon Linux 2, and put your desired environment variables into a systemd override. – Michael Hampton Oct 02 '18 at 12:31

1 Answers1

0

If you want php-fpm service to load /etc/environment, then you can add following line in the Service section:

EnvironmentFile=/etc/environment
andrzej1_1
  • 101
  • 1