Is it possible for the apache2 user, http, to have environment variables like normal users do? How would I go about setting those up, if possible?
apache2用户http是否有可能像普通用户那样拥有环境变量?如果可能的话,我该如何设置它们呢?
2 个解决方案
#1
Your question is not clear about how you want to use the environment variables.
您的问题并不清楚如何使用环境变量。
For consideration: if in /etc/httpd/conf/httpd.conf, you put
需要考虑:如果在/etc/httpd/conf/httpd.conf中,你就放了
SetEnv MYVAR 10
then that environment variable should be available in your scripting language (PHP for example). In PHP, it can be accessed by $_SERVER['MYVAR']
然后,您的脚本语言(例如PHP)中应该提供该环境变量。在PHP中,它可以通过$ _SERVER ['MYVAR']访问
#2
Well, if your http
user has a login shell, which most don't, you could put it in there. But that's still probably not going to do what you really want. I usually accomplish what you're trying to do by putting the environment variables in /etc/init.d/httpd
.
好吧,如果你的http用户有一个登录shell,大部分都没有,你可以把它放在那里。但那仍然可能不会做你真正想要的。我通常将环境变量放在/etc/init.d/httpd中来完成你想要做的事情。
#1
Your question is not clear about how you want to use the environment variables.
您的问题并不清楚如何使用环境变量。
For consideration: if in /etc/httpd/conf/httpd.conf, you put
需要考虑:如果在/etc/httpd/conf/httpd.conf中,你就放了
SetEnv MYVAR 10
then that environment variable should be available in your scripting language (PHP for example). In PHP, it can be accessed by $_SERVER['MYVAR']
然后,您的脚本语言(例如PHP)中应该提供该环境变量。在PHP中,它可以通过$ _SERVER ['MYVAR']访问
#2
Well, if your http
user has a login shell, which most don't, you could put it in there. But that's still probably not going to do what you really want. I usually accomplish what you're trying to do by putting the environment variables in /etc/init.d/httpd
.
好吧,如果你的http用户有一个登录shell,大部分都没有,你可以把它放在那里。但那仍然可能不会做你真正想要的。我通常将环境变量放在/etc/init.d/httpd中来完成你想要做的事情。