求救nginx 配置怎么支持 PATH_INFO?

ihefe 2010-09-03 04:48:12
求救nginx 配置怎么支持 PATH_INFO!
看了很多的配置方法和官方的例子 始终不能成功!求救..!

nginx 0.7.65 + php5.3.2 (FastCGI)+ubuntu 10

############/etc/nginx/nginx.conf
user www-data;
#worker_processes 1;
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_timeout 0;
keepalive_timeout 60;
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_length 1k;
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 [1-6]\.(?!.*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;

index index.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_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
#fastcgi_param SCRIPT_NAME $script;
#fastcgi_param PATH_INFO $path_info;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
....
.....





...全文
2186 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
heyli 2010-09-04
  • 打赏
  • 举报
回复
來了 接分
ihefe 2010-09-03
  • 打赏
  • 举报
回复
ihefe 2010-09-03
  • 打赏
  • 举报
回复
我用的codeigniter框架.. 框架


/*
|--------------------------------------------------------------------------
| 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";


ihefe 2010-09-03
  • 打赏
  • 举报
回复
主要是这句不知道改怎么写 或者 那配置有问题


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错误

5,657

社区成员

发帖
与我相关
我的任务
社区描述
Web开发应用服务器相关讨论专区
社区管理员
  • 应用服务器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧