Apache2:用户http的环境变量
apache2 用户 http 是否可以像普通用户一样拥有环境变量? 如果可能的话,我将如何进行设置?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题不清楚如何使用环境变量。
考虑一下:如果在 /etc/httpd/conf/httpd.conf 中,您输入了
该环境变量,那么该环境变量应该在您的脚本中可用语言(例如 PHP)。 在 PHP 中,可以通过
$_SERVER['MYVAR']
访问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
then that environment variable should be available in your scripting language (PHP for example). In PHP, it can be accessed by
$_SERVER['MYVAR']
好吧,如果您的
http
用户有登录 shell(大多数人没有),您可以将其放在那里。 但这可能仍然无法达到您真正想要的效果。 我通常通过将环境变量放入/etc/init.d/httpd
来完成您想要做的事情。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
.