Setting Server Variables before Apache Loads
We have CentOS with Apache running on it. Basically, I have a few variables in /etc/environment and they're passed through to our Apache configs using PassEnv. The issue is that because Apache is before /etc/environment the variables are not found.
Is there a similar kind of /etc/environment file that I can add my global environmental variables into that is executed before apache (httpd) or do I have to start editing runlevels?
Kind regards,
Steve
Use "/etc/sysconfig/httpd" to set Apache environment.
If these are variables which apply to each and every user on the system, then they should be added in /etc/enviornment - but IIRC this file is not explicitly parsed by the init scripts.
So you'd need to add a line in /etc/rc.d/init.d/functions, e.g.
# -*-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
However if you only want these vars to be available to the webserver, then they should be declared in /etc/sysconfig/httpd, e.g.
# Configuration file for the httpd service.
export MYSQL_USER = mydbuser
(might work without the explicit export).