I've been setting custom env vars for Apache 1 of 2 ways; 1 - Changing the passwd file so Apache has a shell and loading a custom .bashrc file. 2 - Using the SetEnv directive in my httpd.conf file. I'm crazy about neither one as they both have limitations; 1 - I don't like giving Apache its own shell. 2 - The SetEnv directive only takes 2 args so if I have a var with multiple values like a path, it won't work. What's the cleanest way to set complex env vars for Apache?
aurfalien at gmail.com wrote:> What's the cleanest way to set complex env vars for Apache?What are you needing to set such variables for? I've run apache for probably nearly 15 years now, doing many different types of things but never have I had to set complex environment variables. Have you tried sourcing the variables from the init script? One way may be to put the variables in /etc/sysconfig/httpd Perhaps there is a better way to do what you want without needing such environment variables. nate
aurfalien at gmail.com wrote:> I've been setting custom env vars for Apache 1 of 2 ways; > > 1 - Changing the passwd file so Apache has a shell and loading a > custom .bashrc file. > > 2 - Using the SetEnv directive in my httpd.conf file. > > I'm crazy about neither one as they both have limitations; > > 1 - I don't like giving Apache its own shell. > > 2 - The SetEnv directive only takes 2 args so if I have a var with > multiple values like a path, it won't work. > > What's the cleanest way to set complex env vars for Apache?I'm not aware of any exceptions to environment variables being single key/value strings. The value of a path is a single string as far as the environment mechanism goes, even if the code that evaluates it splits on :'s by convention. I don't think there is such a thing as a complex env var. -- Les Mikesell lesmikesell at gmail.com
On Mon, Oct 19, 2009 at 12:49 PM, <aurfalien at gmail.com> wrote:> I've been setting custom env vars for Apache 1 of 2 ways; > > 1 - Changing the passwd file so Apache has a shell and loading a > custom .bashrc file. > > 2 - Using the SetEnv directive in my httpd.conf file. > > I'm crazy about neither one as they both have limitations; > > 1 - I don't like giving Apache its own shell. > > 2 - The SetEnv directive only takes 2 args so if I have a var with > multiple values like a path, it won't work. > > What's the cleanest way to set complex env vars for Apache?I put "export FOO=bar" in /etc/sysconfig/httpd and then PassEnv FOO in httpd.conf. Then scripts (PHP in my case) run by apache inherit FOO in the environment. I can't speak for python though. Don't know why it wouldn't work with what you call complex vars. -- Jeff
Possibly Parallel Threads
- Conflicting TERM env var with SetEnv feature.
- Conflicting TERM env var with SetEnv feature.
- one more try - ENV and FastCGI
- [Bug 3438] New: env var that is SetEnv'ed multiple times in the same SetEnv directive, is sent/printed several times
- Uniquely Identifying the Local TTY of an SSH Connection