There is a problem with the supervisor daemon php process executing getenv ('HOME')

supervisord profile

[program:satis]
command=/usr/local/webserver/php-7.1.15/bin/php artisan queue:work --sleep=3 --tries=2 --daemon
user=www

start supervisord as a root user

then add

to the php
echo exec("whoami"); // output: www

outputs www , but adds

echo getenv("HOME"); // output: /root

gets / root . If you execute

as a www user
php -r "echo getenv("HOME");" 

is / home/www .

I would like to ask why the supervisord executes the php file (starts the supervisord, configuration user www under the root user) and executes getenv ("HOME") will get / root ?

Feb.26,2021

I understand that configuring the user to www, simply tells supervisor to run as the www user when starting the script, but does not perform operations such as su-www itself. So, in fact, the system environment variable did not switch to the past, echo $HOME, it will still output / root . After all, you started the service in root.

Menu