1

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?

3 Answers 3

1

FastCGI Param for fastcgi passing or Proxy Set Header for when proxy passing.

0

Why not just create a launcher script that sets the needed enviroment variables before it calls nginx or rails .. and have one scipt per instance?

0

fastcgi_params will allow you to set environment variables easily. Here's an example of adding environment variables using fastcgi params with php-fpm:

 location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param MY_VARIABLE contents; include fastcgi_params; } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.