Apache2:用户http的环境变量

发布于 2024-07-26 04:20:18 字数 59 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

恬淡成诗 2024-08-02 04:20:18

您的问题不清楚如何使用环境变量。

考虑一下:如果在 /etc/httpd/conf/httpd.conf 中,您输入了

SetEnv MYVAR 10

该环境变量,那么该环境变量应该在您的脚本中可用语言(例如 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

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']

明媚殇 2024-08-02 04:20:18

好吧,如果您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文