Setting Environment Variable for nginx and Rails consumption

Posted by kolrie on Server Fault See other posts from Server Fault or by kolrie
Published on 2010-08-09T14:07:40Z Indexed on 2010/12/25 19:55 UTC
Read the original article Hit count: 214

Apache's module mod_env offers a handy way of setting environment variables in configuration files, like:

<VirtualHost *:80>
  ServerName xyz.com
  DocumentRoot /var/www/rails_app/public
  PassengerAppRoot /var/www/rails_app
  SetEnv MY_VARIABLE contents
</VirtualHost>

http://httpd.apache.org/docs/2.0/mod/mod_env.html#setenv

However, in nginx I couldn't find anything that serves the same purpose. What's the alternative here? I thought of setting environment variables in .profile files (I am using Ubuntu 10.04), but that wouldn't have the same "per vHost" isolation I have with Apache, right?

What are the alternatives here?

© Server Fault or respective owner

Related posts about nginx

Related posts about environment-variables