在Apache加载之前设置服务器variables

我们有运行Apache的CentOS。 基本上,我在/ etc / environment中有一些variables,它们使用PassEnv传递给我们的Apacheconfiguration。 问题是,因为Apache在/ etc / environment之前没有findvariables。

是否有一个类似的/ etc / environment文件,我可以添加我的全局环境variables到Apache(httpd)之前执行,还是我必须开始编辑运行级别?

亲切的问候,

史蒂夫

使用“/ etc / sysconfig / httpd”来设置Apache环境。

如果这些variables适用于系统上的每一个用户,那么它们应该被添加到/ etc / enviornment中 – 但是IIRC这个文件没有被init脚本明确地parsing。

所以你需要在/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 

但是,如果您只希望这些variables可用于Web服务器,则应在/ etc / sysconfig / httpd中声明它们,例如

 # Configuration file for the httpd service. export MYSQL_USER = mydbuser 

(可能没有明确的出口工作)。