Nginx下部署TP5项目

标签(空格分隔): linux


nginx配置文件:

server
{   
    listen 81; 
    #listen [::]:80;
    server_name _;
    index index.html index.htm index.php default.html default.htm default.php;
    root  /home/wwwroot/thinkphp5.0.5/public;

    include rewrite/other.conf;
    #error_page   404   /404.html;

    # Deny access to PHP files in specific directory
    #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

    include enable-php-pathinfo.conf;
    
    # --start--- TP5加上这一块 支持pathinfo
    if (!-e $request_filename) {
        rewrite ^/(.*)$ /index.php/$1 last;
        break;
    }   

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        try_files $fastcgi_script_name =404;
        set $path_info $fastcgi_path_info;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_pass unix:/dev/shm/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
    }   
    # --end--- TP5加上这一块 支持pathinfo


    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {   
        expires      30d;
    }   

    location ~ .*\.(js|css)?$
    {   
        expires      12h;
    }
    
    location ~ .*\.(js|css)?$
    {   
        expires      12h;
    }   

    location ~ /.well-known {
        allow all;
    }

    location ~ /\.
    {
        deny all;
    }

    access_log  /home/wwwlogs/thinkphp5.0.5.log;
}
posted @ 2018-12-11 10:24  TaylorSWMM  阅读(3048)  评论(0编辑  收藏  举报