Ste*_*iff 7 centos environment-variables env apache-2.2
我们在 CentOS 上运行了 Apache。基本上,我在 /etc/environment 中有一些变量,它们使用 PassEnv 传递给我们的 Apache 配置。问题是因为 Apache 在 /etc/environment 之前,所以找不到变量。
是否有类似的 /etc/environment 文件,我可以将全局环境变量添加到在 apache (httpd) 之前执行的文件中,还是必须开始编辑运行级别?
亲切的问候,
史蒂夫
如果这些变量适用于系统上的每个用户,那么它们应该被添加到 /etc/enviornment 中——但是 IIRC 这个文件没有被初始化脚本显式解析。
所以你需要在 /etc/rc.d/init.d/functions 中添加一行,例如
# -*-Shell-script-*-
#
# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
#
# amended to set env vars
TEXTDOMAIN=initscripts
. /etc/environment
Run Code Online (Sandbox Code Playgroud)
但是,如果您只希望这些变量可供 Web 服务器使用,则应在 /etc/sysconfig/httpd 中声明它们,例如
# Configuration file for the httpd service.
export MYSQL_USER = mydbuser
Run Code Online (Sandbox Code Playgroud)
(可能在没有显式导出的情况下工作)。
| 归档时间: |
|
| 查看次数: |
20264 次 |
| 最近记录: |