lnmp1.4 安裝 laravel5.4 的 nginx 配置文件

  • 首先移除很坑的防跨目錄功能
    LNMP 1.4上如果不想用防跨目錄還需要將 /usr/local/nginx/conf/fastcgi.conf 里面的
    fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";刪除
    LNMP 1.4上也可以直接使用lnmp1.4/tools/ 目錄下的 ./remove_open_basedir_restriction.sh 進(jìn)行移除。

LNMP1.4自帶的這個(gè)工具會(huì)刪除網(wǎng)站目錄的.user.ini和nginx的fastcgi.conf里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

  • 重啟nginx。

  • 編輯站點(diǎn)的nginx配置文件 將xxxxx.cn換成你的域名
    vim /usr/local/nginx/conf/vhost/xxxxx.cn.conf

  • 將下面的配置文件貼進(jìn)去

server
    {   
        listen 80;
        #listen [::]:80;

        # server_name 換成你的域名 
        server_name xxxxx.cn ;

        index index.html index.htm index.php default.html default.htm default.php;
        
        # xxxxx.cn 換成你的域名
        root  /home/wwwroot/xxxxx.cn/public;

        # laravel 文檔給的nginx配置
        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        include fastcgi.conf;
        #error_page   404   /404.html;
        include enable-php.conf;



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

        location ~ .*\.(js|css)?$
        {   
            expires      12h;
        }
        location ~ /\.
        {   
            deny all;
        }
        access_log  /home/wwwlogs/info.log;
}
  • 重啟nginx
    /etc/init.d/nginx restart
  • 完成
image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容