Apache的模块mod_env提供了一个在configuration文件中设置环境variables的简便方法,例如:
<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
但是,在nginx中我找不到任何符合相同目的的东西。 这里有什么select? 我想在.profile文件(我使用的是Ubuntu 10.04)中设置环境variables,但这不会有我与Apache的“每vHost”隔离相同,对吧?
这里有什么select?
fastcgi 参数用于fastcgi传递或代理传递时的代理集标题 。
为什么不创build一个启动脚本,在调用nginx或rails之前设置所需的环境variables?并且每个实例都有一个scipt?
fastcgi_params将允许您轻松设置环境variables。 下面是一个用php-fpm使用fastcgi参数添加环境variables的例子:
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; }