天空小小岛技术论坛

 找回密码
 注册
搜索
天空小小岛技术网站 门户 查看主题

Apache中的SetEnv在Nginx里的实现方法

发布者: 一粒米 | 发布时间: 2013-11-29 14:35| 查看数: 10243| 评论数: 0|帖子模式

Apache 中这么写
  1. SetEnv AUTHOR yilimi
复制代码

然后
$_SERVER["AUTHOR"] 的值就是 yilimi

nginx 里用 fastcgi_param 来实现
看样例
  1. server {
  2.         listen 80;
  3.         server_name tkxxd.net;
  4.         access_log /data/tkxxd.net/logs/access.log combined buffer=32k;
  5.         error_log /data/tkxxd.net/logs/error.log warn;

  6.         location / {
  7.                 index index.html index.htm index.php;
  8.                 root /data/tkxxd.net/www/;
  9.         }

  10.         location ~ \.php$ {
  11.                 include fastcgi_params;
  12.                 fastcgi_pass  unix:/dev/shm/php-fcgi.sock;
  13.                 fastcgi_index index.php;
  14.                 fastcgi_param SCRIPT_FILENAME /data/tkxxd.net/www$fastcgi_script_name;
  15.                 fastcgi_param AUTHOR yilimi;
  16.         }
  17. }
复制代码


其中
fastcgi_param AUTHOR yilimi;
就是用来实现这个功能
注意放的位置
最后看 info 的效果图

最新评论

小黑屋|手机版|Archiver|天空小小岛  |京ICP备2025130156号|

GMT+8, 2025-7-3 16:10 , Processed in 0.098813 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表