【发布时间】:2017-10-12 00:17:03
【问题描述】:
我最近在 Windows 7 中安装了 nginx 1.4.4 和 PHP 5.5.8。我运行 nginx.exe 和 php-cgi.exe 来运行服务器并运行。当我在 URL 中发送查询字符串时,如果我 print_r($_GET) 它 具有来自查询字符串的值。但是如果我print_r($_REQUEST),$_REQUEST 只是一个空数组。我在stackoverflow中关注了其他一些问题,我发现的只是检查request_order和variables_order。在 php.ini 中
这是我在 php.ini 中对 request_order 和 variables_order 的当前配置:
; This directive determines which super global arrays are registered when PHP
; starts up. G,P,C,E & S are abbreviations for the following respective super
; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty
; paid for the registration of these arrays and because ENV is not as commonly
; used as the others, ENV is not recommended on productions servers. You
; can still get access to the environment variables through getenv() should you
; need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
; http://php.net/variables-order
variables_order="GPCS"
; This directive determines which super global data (G,P,C,E & S) should
; be registered into the super global array REQUEST. If so, it also determines
; the order in which that data is registered. The values for this directive are
; specified in the same manner as the variables_order directive, EXCEPT one.
; Leaving this value empty will cause PHP to use the value set in the
; variables_order directive. It does not mean it will leave the super globals
; array REQUEST empty.
; Default Value: None
; Development Value: "GP"
; Production Value: "GP"
; http://php.net/request-order
request_order="GP"
我还找到了关闭 auto_globals_jit 的答案,但它不起作用。
我有一个工作安装的 xampp 1.8.3,它在 apache 服务器上工作。但是当nginx使用xampp的PHP时,$_REQUEST也是空的。
有些文章告诉要更改 nginx 配置以在 fastcgi_params 中添加 query_string。但情况是$_SERVER['QUERY_STRING'] 是空的。但就我而言,$_SERVER['QUERY_STRING'] 包含价值。我仍然尝试它,但它也不起作用。
还缺少什么?谢谢。
编辑
这是我的nginx服务器配置(我使用Code Igniter,所以我按照http://wiki.nginx.org/Codeigniter进行配置:
server {
listen 80;
server_name local.dev.com;
root html/dev;
autoindex on;
index index.php;
location / {
try_files $uri $uri/ /index.php;
location = /index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SCRIPT_FILENAME D:/nginx/html/dev$fastcgi_script_name;
include fastcgi_params;
}
}
location ~ \.php$ {
return 444;
}
}
【问题讨论】:
-
你能把你的
fastcgi_param配置从nginx plase 中发布出来吗? -
@Fleshgrinder 你的意思是 nginx.conf 中的 fastcgi_param 吗?我已更新问题以包含配置。