1

On Ubuntu Oneiric 11.10, I thought I'd get clever and add

export RAILS_ENV=production

to /etc/apache2/envvars so I could DRY up my Apache configs. But it doesn't seem to be accessible from httpd.conf. Digging further, I started using ErrorLog as a test, and now I'm baffled. Given the following lines in envvars:

export APACHE_RUN_USER=www-data
export APACHE_RUN_NEWVAR=www-newvar

when I do this:

ErrorLog ${APACHE_LOG_DIR}/${APACHE_RUN_USER}-error.log

I get a file called /var/log/apache2/www-data-error.log as I'd expect. But when I do this:

ErrorLog ${APACHE_LOG_DIR}/${APACHE_RUN_NEWVAR}-error.log

I instead get /var/log/apache2/${APACHE_RUN_NEWVAR}-error.log.

I grepped the package source, and APACHE_LOG_DIR isn't hardcoded anywhere; it shouldn't be special. So what's stopping me from using newly created variables?

3

This is not directly replying to the question but according to passenger documentation, production is the default environment so you shouldn't be needing this line. (I'm guessing you are using passenger)

Edit: I've tried putting PassEnv APACHE_RUN_NEWVAR in my vhost config file and it worked. It wasn't working before.

See the doc :

Specifies one or more native system environment variables to make available as internal environment variables

Edit2: Seems like PassEnv has nothing to do with it. When I reload the config with apache2ctl restart the new variables are not defined but if I do apache2ctl stop then apache2ctl start it works fine...

  • 1
    Yeah, but I want to use the same config file in multiple environments on multiple servers. – Jay Levitt Dec 13 '11 at 3:58
  • Bingo! I have no idea why PassEnv is needed for new vars and not for the "standard" vars, but I'll take it.. – Jay Levitt Dec 13 '11 at 4:59
  • But it gets weirder: serverfault.com/questions/340355/… – Jay Levitt Dec 13 '11 at 5:22
  • Thanks again; I never would have thought to try that. Go answer it on the other one and get more acceptance points! – Jay Levitt Dec 13 '11 at 16:03

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.