Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

1 Answer

up vote 2 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
add comment

Your Answer

 
discard

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.