tpshop的nginx 服务器配置方法

这里造成注意第1个location和第2个location,都要加

第3个location中的,根据不同服务器的.sock加载不同的内容,本服务是这个、

fastcgi_pass unix:/dev/shm/php-cgi.sock;

在官方给的加的是这个

fastcgi_pass  unix:/tmp/php-cgi.sock;

很多情况打不开都是因为它的路径不正确而引起的!

server {

    listen 80;
    server_name (域名名称 eq:/data/wwwroot/banmutian.sxctkj.cc);
    #access_log /data/wwwlogs/banmutian.sxctkj.cc_nginx.log combined;
    index index.html index.htm index.php;
    root (项目路径 eq:/data/wwwroot/banmutian.sxctkj.cc) ;

    location / {
        index  index.htm index.html index.php;  
        if (!-e $request_filename){
            rewrite ^/(.*)$ /index.php?s=$1 last;
            break;
        }
    }

    location ~ /.*.php/ {
                rewrite ^(.*?/?)(.*.php)(.*)$ /$2?s=$3 last;
        break;
    }


    location ~ .php {
        fastcgi_pass unix:/dev/shm/php-cgi.sock;
        fastcgi_index index.php;
        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;
    }

}
文章导航