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