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.
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.