0

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:

/etc/apache2/envvars:

export RAILS_ENV=production
export OUR_HOST_NAME='web.production.example.com'

/etc/apache2/sites-enabled/example:

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

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

${OUR_HOST_NAME}-error.log
production-access.log

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

2
  • 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, 2011 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. Dec 13, 2011 at 22:46

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .