衫裤跑路 2011-11-11 19:27 采纳率: 50%
浏览 207
已采纳

变量类似于 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条回答 默认 最新

  • lrony* 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条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?