dsxd62219570 2018-09-05 14:25
浏览 260

Ubuntu 16.04 + Supervisor + Nginx + PHP-FPM 7.2:无法使环境变量正常工作

I'm tearing my hair out with this, but I've probably missed something obvious. My issue is I can't get environment variables set in /etc/environment working via FPM. This is what I have:

Supervisor configuration

[program:nginx]
command=/usr/sbin/nginx
stdout_logfile=/var/log/supervisor/program_supervise_nginx.log
stderr_logfile=/var/log/supervisor/program_supervise_nginx.error
priority=100
user=root
autostart=true
autorestart=true
EnvironmentFile=/etc/environment


[program:fpm]
command=/usr/sbin/php-fpm7.2 --nodaemonize -c /etc/php/7.2/fpm/php-fpm.conf
user=root
autostart=true
autorestart=true
priority=5
stdout_events_enabled=true
stderr_events_enabled=true
EnvironmentFile=/etc/environment

FPM pool configuration

[domain]
...
clear_env = no
...

php.ini (/etc/php/7.2/fpm/php.ini)

...
variables_order = "EGPCS"
...

I can set environment variables directly in the pool configuration and this works via FPM, e.g. if I have this configuration in my fpm pool -

[domain]
...
clear_env = no
env[FOO] = bar
...
  • then I can access "FOO" using getenv["FOO"] via FPM.

The problem I simply can't load in /etc/environment.

I've seen other posts mentioning having to explicitly include my environment variables as fast_cgi params in nginx, however, given that my supervisor config for FPM is explicitly setting the environment, I was hoping to avoid this step (and of course - avoid the duplication of setting vars in two places)

Any ideas anyone!? Any assistance much appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式