Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
apache2 用户 http 是否可以像普通用户一样拥有环境变量?如果可能的话,我将如何进行设置?
您的问题不清楚您想如何使用环境变量。
供考虑:如果在 /etc/httpd/conf/httpd.conf 中,你把
SetEnv MYVAR 10
那么该环境变量应该在您的脚本语言(例如 PHP)中可用。在 PHP 中,它可以通过以下方式访问$_SERVER['MYVAR']
$_SERVER['MYVAR']
好吧,如果你的http用户有一个登录 shell,而大多数人没有,你可以把它放在那里。但这仍然可能不会做你真正想要的。我通常通过将环境变量放入/etc/init.d/httpd.
http
/etc/init.d/httpd