Nginx下部署Laravel項目


Nginx下部署Laravel項目

標簽(空格分隔): php

Nginx配置文件

    listen 80 default_server;
    #listen [::]:80 default_server ipv6only=on;
    server_name _;
    index index.html index.htm index.php;
    #root  /home/wwwroot/default;
    root  /home/wwwroot/web.laravel.cn/public;
    
    
    location /nginx_status
    {
        stub_status on;
        access_log   off;
    }
    
    location / { 
        try_files $uri $uri/ /index.php?$query_string;
    }


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

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

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

    location ~ /\.
    {
        deny all;
    }

    access_log  /home/wwwlogs/access.log;

注意點

1 根目錄要寫對 /home/wwwroot/web.laravel.cn/public 要指向你的項目入口文件

2 如果出現 除/根目錄外 其他路由都不能訪問
    2.1 首先在配置文件添加 

    laravel => https://laravel.com/docs/5.0/installation#pretty-urls
    
    2.2 修改fastcgi.conf

    2.3 修改項目根目錄下的.user.ini 
        修改如果無法寫 請修改權限
        chattr -i /home/wwwroot/web.laravel/public/.user.ini


vim 打開


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM