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='web.production.example.com'


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.

  • 1
    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
  • 2
    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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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