TP5和Laravel5.7 Nginx配置

server {
        listen  80;
        server_name zhou.tp.com;
        set $root_path 'E:\Xteam\public';
        root $root_path;

        index index.php index.html index.htm;

        #hide index.php
    location / {
        # yii2 框架的 /site/index?name=sallency&age=25 模式的 rewrite 方法
        #try_files $uri $uri/ /index.php$is_args$args;
        # tp 框架的 /site/index/name/sallency/age/25 模式的 rewrite 方法
        #try_files $uri $uri/ /index.php/$uri;
        # 虽然 if 不规范但 rewrite 还是很方便的 可以兼容 yii2 和 tp 的 pathinfo 模式
        if (!-e $request_filename){
           rewrite ^/(.*)$ /index.php/$1 last;
           break;
        }
    }

        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

        location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {

        }

        location ~ /\.ht {
            deny all;
        }
    }



server {
        listen  80;
        server_name zh.tp.com;
        set $root_path 'E:\zhou\public';
        root $root_path;

        index index.php index.html index.htm;

       #hide index.php
       location / {
          if (!-e $request_filename){
             rewrite ^/(.*)$ /index.php/$1 last;
              break;
          }
       }

        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

        location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {

        }

        location ~ /\.ht {
            deny all;
        }
 }







server {
     listen  80;
     server_name  i.lov.me;
     set $root_path 'E:\shuai\public';
     root $root_path;

    add_header X-Frame-Options "SAMEORIGIN";   
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Content-Type-Options "nosniff"; 

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }  
    location = /robots.txt  { access_log off; log_not_found off; }  

    error_page 404 /index.php;

    location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {

    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}





你可能感兴趣的:(TP5和Laravel5.7 Nginx配置)