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!

4
  • how is php-fpm started? Commented Sep 28, 2018 at 3:01
  • Why do you believe that php-fpm would ever read /etc/environment? Commented Oct 2, 2018 at 4:08
  • @MichaelHampton welp how/where else would I set environment variables that can be read by both php-fpm and php cli? Commented Oct 2, 2018 at 4: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. Commented Oct 2, 2018 at 12:31

1 Answer 1

0

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

EnvironmentFile=/etc/environment 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.