I am running PHP apps on a webserver with apache2 (v2.4.25) and php7.1-fpm.
I need to share env var for both php7.1-fpm and php CLI script.
I edit /etc/php/7.1/fpm/pool.d/www.conf
as folow:
env['MYVAR']= thisismyvar
The access by the web apps is OK using the getenv('MYVAR')
But I need this env var to be set for my CLI script too.
This test command does not return anything: sudo -u www-data env | grep MYVAR
My question is: how can I share env var for php-fpm (with apache2) and php CLI scripts without copying/pasting?
My apache2 vhost:
<VirtualHost *:80>
ServerName app.company
DocumentRoot /var/www/app1/app/public/
<Directory /var/www/poll>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
# Apache 2.4.10+ can proxy to unix socket
SetHandler "proxy:unix:/var/run/php/php7.1-fpm.sock|fcgi://localhost/"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/app1-error.log
CustomLog ${APACHE_LOG_DIR}/app1-access.log combined
</VirtualHost>