求救nginx 配置怎么支持 PATH_INFO!

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

nginx 0.7.65 + php5.3.2 (FastCGI)+ubuntu 10
我用的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";
$config['uri_protocol'] = "ORIG_PATH_INFO";//设置这样全部连接都是1个页面




############/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;
....
.....



主要是这句不知道改怎么写 或者 那配置有问题
比如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
这样是成功

但是 http://192.168.1.122/web/index.php/task/
http://192.168.1.122/web/index/task/
这样就出现 404错误


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;
}


没办法到应用服务器没人只能来php区 ,帮帮忙
...全文
175 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ihefe 2010-09-04
  • 打赏
  • 举报
回复
谢了..

还有个贴随便 帮我解了http://topic.csdn.net/u/20100903/16/148ff89a-a00c-4f25-862c-5135efd00969.html

ihefe 2010-09-03
  • 打赏
  • 举报
回复
呃.. 解决了.. 散分
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;
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;

#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_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;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;




ihefe 2010-09-03
  • 打赏
  • 举报
回复
大哥大姐 别忙着放假..帮我看看!!
ihefe 2010-09-03
  • 打赏
  • 举报
回复

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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