I've defined some environment variables like APP_ENV in my /etc/environment file, on my ArchLinux.
If I type printenv, I see them.
I've created this simple test file called… test.php
<?php var_dump(getenv('APP_ENV')); var_dump(getenv()); If I run php test.php, everything is OK, I see my ENV variables.
But when I try to access the file via HTTP… there is nothing in my env!
Of course, I've changed the config of /etc/php/php-fpm.d/www.conf to set clear_env = no
These are the affected lines:
; Clear environment in FPM workers ; Prevents arbitrary environment variables from reaching FPM worker processes ; by clearing the environment in workers before env vars specified in this ; pool configuration are added. ; Setting to "no" will make all environment variables available to PHP code ; via getenv(), $_ENV and $_SERVER. ; Default Value: yes clear_env = no And I've restarted both php-fpm and nginx services but… still nothing in my env. Script return bool(false).
So… Am I missing something ?
This is my php-fpm version:
php-fpm --version PHP 7.2.6 (fpm-fcgi) (built: May 26 2018 07:45:18) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies And my Nginx version
nginx -v nginx version: nginx/1.14.0 What should I do to access my env variables in a PHP-FPM context ?
Thanks a lot!