[Thinkphp5]部署nginx

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.xxx.cn xxx.cn;#填写自己的服务器名
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.xxx.cn/public;
        #error_page   404   /404.html;
        
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
           expires  30d;
        }
        
        location ~ .*\.(js|css)?$
        {
           expires 12h;
        }
        
        location / {
          if (!-e $request_filename) {
             rewrite ^(.*)$ /index.php?s=$1 last;
             break;
          }
        }
        
        #pathinfo配置 使支持tp5的标准url
        location ~ .+\.php($|/) {
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;    #不支持的改为:127.0.0.1:9000;
            fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
            include fastcgi_params;
        }   
             
        location ~ /\.
        {
            deny all;
        }
        
        access_log  /home/wwwlogs/www.xxx.cn.log;
    }


头像
QQ登录: