nginx 下使用Kohana PHP的配置

时间:2011-3-6     作者:smarteng     分类: 服务器相关


location / {

    index index.php index.html index.htm;
    try_files $uri $uri/ index.php$uri?$args;
}
 
location ~ ^(.+.php)(.*)$ {
    fastcgi_split_path_info ^(.+.php)(.*)$;
    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  SCRIPT_FILENAME    $document_root/$fastcgi_script_name;
    fastcgi_param  PATH_INFO          $fastcgi_path_info;
 
    include fastcgi.conf;
 
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
}
server {
    listen       80;
    server_name  a.dangdang.com;
    index index.html index.htm index.php;
    root  /var/www/hosts/union/web;
    log_format main_order1 '$remote_addr |-| $remote_user [$time_local] |'
    '"$request" $status $bytes_sent |'
    '"$http_referer" : "$http_user_agent" |';

location / {
       if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
        }
}
 
    location ~ .*\.(php|php5)?$ {
              fastcgi_pass    127.0.0.1:9000;
              fastcgi_index   index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              #fastcgi_param SCRIPT_FILENAME /www/hosts/web/test.php;
              include         fastcgi_params;
              break;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires      30d;
    }
    location ~ .*\.(js|css)?$ {
        expires      1h;
    }
    set  $path_info "";
    location /index.php {
        if ($uri ~ "^/index.php(/.+)$") {
            set  $path_info  $1;
        }
        fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
        include  /usr/local/nginx/conf/fcgi.conf;
        fastcgi_param  PATH_INFO $path_info;
        fastcgi_param  SCRIPT_FILENAME  /www/hosts/web/ndex.php;
        access_log    /www/logs/access.union.log;
    }
}