ThinkPHP 3.23和5.0 Laravel Nginx配置

来源:互联网 发布:spss23 mac破解 编辑:程序博客网 时间:2024/06/05 18:13

 thinkphp 3.23  'URL_MODEL' => '2' 支持rewrite模式   Nginx配置



server {
        listen       8080;
        server_name  localhost;


        root   "D:/phpStudy/WWW/yl/";


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



location ~* ^.+\.(jpg|gif|png|jpeg|bmp|swf|mp4|avi|3gp|rmvb|gif|wmv|mkv|mpg|vob|mov|flv|swf|ape|wma|aac|mmf|amr|m4a|m4r|ogg|wav|wavpack|mp3)$ {  
            root D:/phpStudy/WWW/yl/;  
            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;
        }


    }


thinkphp 5.0 和laravel的配置文件大致一样  将目录定到public下面   下面是我的详细配置


server {
        listen  8092;  
        server_name localhost;  
        set $root_path 'D:/phpStudy/WWW/xiaodi/public';  
        root $root_path;  


        index index.php index.html index.htm;  


        try_files $uri $uri/ @rewrite;  


        location @rewrite {  
            rewrite ^/(.*)$ /index.php?_url=/$1;  
        }  


        location ~ \.php {  


            fastcgi_pass 127.0.0.1:9000;  
            fastcgi_index /index.php;  


            fastcgi_split_path_info       ^(.+\.php)(/.+)$;  
            fastcgi_param PATH_INFO       $fastcgi_path_info;  
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;  
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
            include                       fastcgi_params;
        }  


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


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


原创粉丝点击