laravel nginx静态化,绝对可以的

server
{
    listen       80;
    server_name www.baidu.com;
    index index.html index.htm index.php default.html default.htm default.php;
    root  /home/wwwroot/www.baidu.com/public;

    #include other.conf;
    location ~ .*\.(php|php5)?$
        {
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
        }

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

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

     if (!-d $request_filename)
            {
                rewrite ^/(.+)/$ /$1 permanent;
            }

            # removes trailing "index" from all controllers
            if ($request_uri ~* index/?$)
            {
                rewrite ^/(.*)/index/?$ /$1 permanent;
            }

            # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
            if (!-e $request_filename)
            {
                rewrite ^/(.*)$ /index.php?/$1 last;
                break;
            }

    access_log  /home/wwwlogs/www.baidu.com.log;
}



然后还有一个地方小伙伴容易忽视,那就是在权限方面,一般安装之后,用户一般是www www 的权限,然后你登录可能是root账户登录上传,你要该成www的用户和组,小坑慎踩。

 

posted @ 2016-12-07 17:48  工头叫你搬砖  阅读(2265)  评论(0)    收藏  举报