Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I started asking this in Creating new variables in /etc/apache2/envvars?. I'm trying to DRY up my Apache config by declaring a few server-specific variables in /etc/apache2/envvars and then using them in my httpd.conf, but I'm having trouble getting apache to recognize the new variables.

As @ouranos discovered, I can use PassEnv to declare new variables.. but only ONE new variable: RAILS_ENV. Watch this:


export RAILS_ENV=production
export OUR_HOST_NAME=''


ErrorLog ${APACHE_LOG_DIR}/${OUR_HOST_NAME}-error.log
CustomLog ${APACHE_LOG_DIR}/${RAILS_ENV}-access.log combined

ls -1 /var/log/apache2 *-*:


What? Switching the order of the two variables in PassEnv has no effect, either.

share|improve this question
Actually I realised than depending on how apache was restarted the variables were correctly defined. See my second edit on your first question and let me know if it changes anything. – ouranos Dec 13 '11 at 6:08
Don't get thrown off by PassEnv, it appears to be a red-herring (See @ouranos's updated comments). I don't use it, and I define multiple variables. I use this strategy on both Ubuntu and RHEL systems. – Stefan Lasiewski Dec 13 '11 at 22:46
up vote 3 down vote accepted

As said on the other question you may have to do apache2ctl stop && apache2ctl start as apache2ctl restart doesn't seem to read changes in the envvars file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.