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的用户和组,小坑慎踩。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM