问题原文
原帖链接 · Aidan Ewen · CC BY-SA 3.0
I'm running php7-fpm in a docker container. However my php scripts aren't able to access environments variables set in my docker-compose file. getenv('MY_ENV_VAR') returns FALSE.
I've changed /etc/php/7.0/fpm/pool.d/www.conf to include clear_env = no and restarted with service php7.0-fpm restart but my environment variables start aren't there.
I've also tried editing /etc/php/7.0/fpm/php.ini includes the line variables_order = "EGPCS".
When I exec into my container on a bash shell I can see that my variables exist. It's just that they're not accessible in my php scripts.
What am I missing?
社区高分解答
原帖链接 · Thiago Pereira · CC BY-SA 4.0
This is a PHP-FPM prank.
- Setup the
clear_env = noon/etc/php/7.2/fpm/pool.d/www.conf, so;
On Dockerfile start de php-fpm with init.d, not use service.
Ex:
CMD /etc/init.d/php7.2-fpm start && nginx -g 'daemon off;'
Check environment variables now
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
