求救nginx 配置怎么支持 PATH_INFO?
求救nginx 配置怎么支持 PATH_INFO!看了很多论坛的配置方法和官方的例子 始终不能成功!求救..!
nginx 0.7.65 + php5.3.2 (FastCGI)+ubuntu 10
############/etc/nginx/nginx.conf
user www-data;
#worker_processes1;
worker_processes 8;
error_log/var/log/nginx/error.log;
pid /var/run/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process. 2010 9.1
worker_rlimit_nofile 10000;
events {
use epoll;
#worker_connections 1024;
worker_connections 10000;
# multi_accept on;
}
http {
#upstream myproject {
#server 127.0.0.1:8000 weight=3;
#server 127.0.0.1:8001;
#server 127.0.0.1:8002;
#server 127.0.0.1:8003;
#}
include /etc/nginx/mime.types;
access_log/var/log/nginx/access.log;
#charset utf-8;
sendfile on;
tcp_nopush on;
#keepalive_timeout0;
keepalive_timeout60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_disable "MSIE \.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
########/etc/nginx/sites-enabled/default
server {
listen 80;
server_name 192.168.1.122;
access_log/var/log/nginx/localhost.access.log;
location / {
root /var/www;
indexindex.html index.htm index.php;
if (-f $request_filename) {
expires max;
break;
}
if (!-e $request_filename) {
rewrite ^/web/(.*)$ /web/index.php/$1 last;
#rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php
{
root /var/www;
fastcgi_index index.php;
fastcgi_pass 192.168.1.122:900;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
}
location ~^/NginxStatus {
stub_status on;
access_log off;
}
}
########/etc/nginx/fastcgi_params
fastcgi_paramSCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_paramGATEWAY_INTERFACE CGI/1.1;
fastcgi_paramSERVER_SOFTWARE nginx;
#fastcgi_param SCRIPT_NAME $script;
#fastcgi_param PATH_INFO $path_info;
fastcgi_paramQUERY_STRING $query_string;
fastcgi_paramREQUEST_METHOD $request_method;
fastcgi_paramCONTENT_TYPE $content_type;
fastcgi_paramCONTENT_LENGTH $content_length;
....
.....
##ci
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.The default setting of "AUTO" works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = "AUTO";
主要是这句不知道改怎么写 或者 那配置有问题
location ~ \.php
{
root /var/www;
fastcgi_index index.php;
fastcgi_pass 192.168.1.122:900;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
}
比如http://192.168.1.122/web/ 和 http://192.168.1.122/web 这样是成功
但是 http://192.168.1.122/web/index.php/task/这样就出现 404错误 没人吗.:dizzy:
http://192.168.1.122/web/ 和 http://192.168.1.122/web
http://192.168.1.122/web/index 和 http://192.168.1.122/web/index.php
这样是成功
其他的都错误
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.The default setting of "AUTO" works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = "ORIG_PATH_INFO";
这样出现全部页面都是主页 对于Nginx,不建议在fastcgi下开启path_info,会产生文件上传安全漏洞,除此之外最好在程序中手动关闭:
@ini_set('cgi.fix_pathinfo', 0); 谢谢问题解决了!
nginx配置
server {
listen 80;
server_name 192.168.1.122;
#charset utf-8;
access_log/var/log/nginx/localhost.access.log;
location / {
root /var/www;
indexindex.html index.htm index.php;
if (-f $request_filename) {
expires max;
break;
}
if (!-e $request_filename) {
rewrite ^/web/(.*)$ /web/index.php/$1 last;
#http://**/web/index?/admin/task
#http://**/web/index.php?/task
#http://**/web/index.php/task
}
}
location ~ \.php
{
root /var/www;
fastcgi_index index.php;
fastcgi_pass 192.168.1.122:900;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
}
###fastcgi_params文件
fastcgi_paramSCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_paramGATEWAY_INTERFACE CGI/1.1;
fastcgi_paramSERVER_SOFTWARE nginx;
#fastcgi_param SCRIPT_NAME $script;
#fastcgi_param PATH_INFO $path_info;
fastcgi_paramQUERY_STRING $query_string;
fastcgi_paramREQUEST_METHOD $request_method;
fastcgi_paramCONTENT_TYPE $content_type;
fastcgi_paramCONTENT_LENGTH $content_length;
fastcgi_paramSCRIPT_NAME $fastcgi_script_name;
fastcgi_paramREQUEST_URI $request_uri;
fastcgi_paramDOCUMENT_URI $document_uri;
fastcgi_paramDOCUMENT_ROOT $document_root;
fastcgi_paramSERVER_PROTOCOL $server_protocol;
fastcgi_paramGATEWAY_INTERFACECGI/1.1;
fastcgi_paramSERVER_SOFTWARE nginx/$nginx_version;
fastcgi_paramREMOTE_ADDR $remote_addr;
fastcgi_paramREMOTE_PORT $remote_port;
fastcgi_paramSERVER_ADDR $server_addr;
fastcgi_paramSERVER_PORT $server_port;
fastcgi_paramSERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_paramREDIRECT_STATUS 200;
页:
[1]