centos ngnix 配置thinkphp 当模式为2的时候

来源:互联网 发布:notepad js格式化插件 编辑:程序博客网 时间:2024/05/22 16:48
server {
listen 80;
server_name ipadd tgjshopv.szczxx.cn;


#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename) {
 rewrite ^/index.php(.*)$ /index.php?s=$1 last;
 rewrite ^(.*)$ /index.php?s=$1 last;
 break;
 }



access_log /data/wwwlogs/t4.mhealthyun.com_nginx.log combined;
index index.html index.htm index.php;
 #如果文件不存在则尝试TP解析  
 try_files  $uri  /index.php$uri;
include /usr/local/nginx/conf/thinkphp.conf;
root /data/wwwroot/tgjshopv;




location ~ \.php {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;


    fastcgi_split_path_info  ^(.+\.php)(/.*)$;
    fastcgi_param  PATH_INFO $fastcgi_path_info;


    include fastcgi_params;
    set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
        set $real_script_name $1;
        set $path_info $2;
        }
    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    fastcgi_param SCRIPT_NAME $real_script_name;
    fastcgi_param PATH_INFO $path_info;
    }


location ~ .+\.php($|/) {


        #fastcgi_pass   127.0.0.1:9000;  
        #fastcgi_index  index.php;  


        #设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,  
        #后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置  
        fastcgi_split_path_info  ^(.+\.php)(/.*)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;


        #加载Nginx默认"服务器环境变量"配置  
        include        fastcgi.conf;

    }


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
     expires 30d;
      access_log off;
      }
  location ~ .*\.(js|css)?$ {
      expires 7d;
      access_log off;
      }
  }

0 0