为 apache 用户 www-data 设置环境变量

nul*_*ser 2 apache-http-server environment-variables

我想GNUPGHOME=/path/to/home为 apache 用户设置环境变量www-data。我尝试设置GNUPGHOME里面/etc/profile

if [ "`id -u`" -eq 33 ]; then
    export GNUPGHOME="/path/to/home"
fi
Run Code Online (Sandbox Code Playgroud)

这里 33 是​​ user 的用户 ID www-data。但是,即使在我重新启动su www-data并运行后,echo $GNUPGHOME我也看到未设置该变量。

我如何才能设置用户www-dataGNUPGHOME变量?

nul*_*ser 5

/etc/apache2/envvars我添加了一个名为的文件,它export GNUPGHOME="/path/to/home"可以执行我想要的操作。