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 优质github账号直接兑换rmb,感兴趣伙伴可以私信
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
    • ¥15 安装svn网络有问题怎么办
    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)