Meike Stone said the following on 03/05/2013 03:40 AM:
Last question. Should I only avoid to set global variables, or is it in general not recommended to use env variables with apache.
And in that wording you have it. It seems to me that you are confusing 'variables' - that which gets altered - with 'settings' - which don't. If I'm understanding correctly, all this is in the context of Apache and web services and not in the general context of J Random Program running on the machine or cluster. HOSTNAME is not a "global variable", it is a host level setting. That doesn't make it 'global' in my mind. You might be running Apache on a cluster of machines each with their own HOSTNAME. It is the settings internal to the Apache services and how the Apache server responds to an outside request that can be viewed as an 'identity' of the server. I mention this because I have in the past set up a 'load balanced' arrangement using round-robin DNS Apache service with initially 2, later 3 and then just to show the point 5 host machines. Each machine had its own HOSTNAME. As far as the client was concerned it was all one service. That, within a shell, you can alter the environment variable HOSTNAME has nothing to do with the system setting of the file /etc/HOSTNAME. Look at 'man 1 hostname' for example. <quote> Note, that only the super-user can change the names. </quote> As others have pointed out, many services clear their environment variables. Clearing HOSTNAME won't affect what's returned by 'gethostname(2)' or gethostname(3)'. Similarly the information returned by 'uname(2)'.
I use this variables to set path variables for eg. logfiles, certificates. If you have eg. 100 vhots, it is really easier to manage them.
This sounds like the way one of the ISPs I use for web services, Dreamhost, has it set up. I gather its a pretty normal way to set up such a service.
My colleges, who are responsible for this vhosts, only get the variables. Configuration for pathes (eg. other mountpoint ..) changes, so I only have to change the environment variables. What makes it so dangerous to us this mechanism, provided by apache, to use for set logfile path?
I don't think its dangerous. I think your understand of Apache and vhosts is getting confused with that of a generic server. The whole point of the vhost is that it shares an IP address but not the 'hostname'. Not the lower case. The Apache docco gives an example of using DNS to map various hostnames - not the lower case - all running on the same machine (and hence sharing a HOSTNAME). All these are SETTINGS not variables. For any single vhost the location of the document root, the location of the log files is SET and cannot be altered by the processes running under that invocation of the server. In my case with Dreamhost I have a an account (~anton) and when I want to set up a web service of any kind the cPanel interface first asks me which of my registered domains to use. I may have to create a new subdomain of - for example - 'antonaylward.com'; blog, webmail, gallery, wiki ... whatever. The cPanel interface then suggests locations under ~anton for the document root etc. I can't put it under, say, ~meikestone. The code behind the cPanel then creates the necessary vhost and if necessary the domain. All this has to match up. Once done I can't alter the entry in /etc/http.d/conf/vhosts.d What's in there is SETTINGS, not variables. Maybe I'm stating a pile of stuff here that's obvious to you, but I'm not sure. You do seem confused about something. I say 'confused' because I think you are misunderstanding something very basic about how Apache and vhosts work. Look: there is a web service at 'mail.antonaylward.com. If you run 'dig mail.antonaylward.com' you will see there is a legitimate DNS entry: ;; ANSWER SECTION: mail.antonaylward.com. 14400 IN A 208.113.200.129 Now if you ping 'mail.antonaylward.com' you get PING mail.antonaylward.com (208.113.200.129) 56(84) bytes of data. 64 bytes from sub5.mail.dreamhost.com (208.113.200.129): ... That's 'cos 'ping' does a reverse DNS lookup of what it finds when it does a forward DNS lookup on 'mail.antonaylward.com' The HOSTNAME is sub5.mail.dreamhost.com. The hostname is mail.antonaylward.com - that's what in the vhost settings.[1] Of course being a shared server there are going to be many domain entries that to the same IP address :-) That's the whole point of shared services like vhosts. So I'm in the same situation as the colleagues you mention. I only get the end result of what the 'automated sysadmin' that is the scripts behind cPanel sets. I don't have the authority to alter the vhosts.d/*.antonaylward.com entries for the various domains and services I've set up using cPanel. Automation is a good thing; it means consistency and once you've debugged it, reliable service. The constraints I have as a customer of an ISP aren't a restriction as far as I'm concerned. If I was that concerned I'd ask to have a 'real' virtual host and do all the admin myself and probably buqqer something up. If I want to play, experiment and learn from buqqering up things I have scratch machines for that sole purpose.
PS: HOSTNAME was only a example for a global variable ;-)
A bad example since its not a really variable. See above for reference to the MAN pages. Please also read the entry in the bash man page for HOSTFILE. I suspect you getting confused with the way environment variables are set and managed under DEC's VMS. [1] Actually this example is for the mail or webmail server rather than the generic web server, but the principle still applies. -- The truth of a proposition has nothing to do with its credibility. And vice versa. Excerpt from the notebooks of Lazarus Long, from Robert Heinlein's "Time Enough for Love" -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org