Nginx运行Laravel的配置 (这里要注意 laravel 的路径 默认是 pathinfo)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hjh15827475896/article/details/81875433

Nginx运行Laravel的配置

修改nginx.conf。修改前记得备份一下,万一改错了还能还原回去。

server {  
        listen  80;    
        server_name localhost;    
        set $root_path '/usr/local/app/snsprj/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;    
        }    
    }

猜你喜欢

转载自blog.csdn.net/hjh15827475896/article/details/81875433