local-host 2011-11-11 19:27 采纳率: 100%
浏览 611
已采纳

变量类似于 Apache 中的 SetEnv?

I use SetEnv in Apache to set some variables in virtualhosts that I recover in PHP using $_SERVER[the_variable].

Now I am switching to Perl Catalyst and Nginx, but it seems that the "env" directive in Nginx is not the same. It does not work. How can it be accomplished?

Here is the background picture, just in case someone can suggest a better approach or my previous system does not work with Nginx.

  • I use the same app for many domains. All data comes from different databases with the same structure.
  • The database name is hardcoded to the virtual host, in that environmental variable.
  • As I know the database name, all the queries go to its appropriate database, from the very first query.
  • I can have multiple domains using the same database, just including the same variable into the directives.

转载于:https://stackoverflow.com/questions/8098927/nginx-variables-similar-to-setenv-in-apache

  • 写回答

4条回答 默认 最新

  • python小菜 2011-11-11 19:50
    关注

    NGINX doesn't manage your backend processes like apache does, so it can't affect their environments. To set a new $_SERVER PHP variable from NGINX, you need to add a new fastcgi_param entry along with the rest of them. Wherever you're including fastcgi_params or fastcgi.conf.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog