[CentOS] apache env vars - best practices
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? ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
aurfal...@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 ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
Hi Nate, We have our internal server running scripts and referencing variables in custom paths. So for example; Some one runs a Python script of http://intranet/batch The batch.py references some variables defined in certain paths. I need a good way of defining a path with multiple vars like FOO=/foo:/ bar... etc... I'm not having too much luck with setting vars in /etc/sysconfig/httpd either. On Oct 19, 2009, at 10:58 AM, nate wrote: > aurfal...@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 > > > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
aurfal...@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 lesmikes...@gmail.com ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
Hi Les, What I mean is that if I use the Apache directive; SetEnv BATCHPATH /foo It works. If I set; SetEnv BATCHPATH /foo:/bar Apache errors with a syntax that SetEnv takes 2 args only, a key and a value. I need multiple values for 1 key, as one would see in a standard mix env. Any ideas? On Oct 19, 2009, at 11:11 AM, Les Mikesell wrote: > aurfal...@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 >lesmikes...@gmail.com > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
aurfal...@gmail.com wrote: > Hi Nate, > > We have our internal server running scripts and referencing variables > in custom paths. > > So for example; > > Some one runs a Python script of http://intranet/batch > > The batch.py references some variables defined in certain paths. > > I need a good way of defining a path with multiple vars like FOO=/foo:/ > bar... etc... Could you not have the scripts themselves grab the variables? nate ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
aurfal...@gmail.com wrote: > Hi Les, > > What I mean is that if I use the Apache directive; > > SetEnv BATCHPATH /foo > > It works. > > If I set; > > SetEnv BATCHPATH /foo:/bar > > Apache errors with a syntax that SetEnv takes 2 args only, a key and a > value. > Doesn't for me on stock Apache in CentOS 5.3. You have something unique going there? Suppose you counld try enclosing the value in double quotes... -Alan ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
Hi Nate, These scripts are called by the user in a standard env and would prefer it to stay un modified when running via Apache. On Oct 19, 2009, at 11:17 AM, nate wrote: > aurfal...@gmail.com wrote: >> Hi Nate, >> >> We have our internal server running scripts and referencing variables >> in custom paths. >> >> So for example; >> >> Some one runs a Python script of http://intranet/batch >> >> The batch.py references some variables defined in certain paths. >> >> I need a good way of defining a path with multiple vars like FOO=/ >> foo:/ >> bar... etc... > > Could you not have the scripts themselves grab the variables? > > nate > > > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
aurfal...@gmail.com wrote: > Hi Les, > > What I mean is that if I use the Apache directive; > > SetEnv BATCHPATH /foo > > It works. > > If I set; > > SetEnv BATCHPATH /foo:/bar > > Apache errors with a syntax that SetEnv takes 2 args only, a key and a > value. Doesn't happen here. If I paste that line into my httpd.conf, apache digests it and reports this in /server-info: Current Configuration: In file: /etc/httpd/conf/httpd.conf 1: SetEnv BATCHPATH /foo:/bar -- Les Mikesell lesmikes...@gmail.com ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
aurfal...@gmail.com wrote: > Hi Nate, > > These scripts are called by the user in a standard env and would > prefer it to stay un modified when running via Apache. How about a wrapper script then? The wrapper could set the vars and then call the unmodified script nate ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
>> Hi Les, >> >> What I mean is that if I use the Apache directive; >> >> SetEnv BATCHPATH /foo >> >> It works. >> >> If I set; >> >> SetEnv BATCHPATH /foo:/bar >> >> Apache errors with a syntax that SetEnv takes 2 args only, a key >> and a >> value. >> > You have something unique going there? Yea, the fact that I'm an idiot! As usual, my typing is killing me and multiple values are fine, it was just a syntax error of my doing. Sorry for the wasted traffic on this one. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
On Mon, Oct 19, 2009 at 12:49 PM, 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 ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
aurfal...@gmail.com wrote: > Hi Les, > > What I mean is that if I use the Apache directive; > > SetEnv BATCHPATH /foo > > It works. > > If I set; > > SetEnv BATCHPATH /foo:/bar > > Apache errors with a syntax that SetEnv takes 2 args only, a key and a > value. > > I need multiple values for 1 key, as one would see in a standard mix > env. > > Any ideas? Which Apache version? I put your second example into my httpd.conf and didn't see any errors. I do see the error you report if I insert a space into the path. -- Bowie ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] apache env vars - best practices
>> Hi Les, >> >> What I mean is that if I use the Apache directive; >> >> SetEnv BATCHPATH /foo >> >> It works. >> >> If I set; >> >> SetEnv BATCHPATH /foo:/bar >> >> Apache errors with a syntax that SetEnv takes 2 args only, a key >> and a >> value. >> >> I need multiple values for 1 key, as one would see in a standard mix >> env. >> >> Any ideas? > > I do see the error you report if I insert a space into the path. I'm an adiot. A typo caused the errors and my typing or beyond horrid. I must say, this is the nicest list, every one willing to help. Thanks foe the response. ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos