首頁  >  文章  >  後端開發  >  yii 後台配置獨立子網域的方法

yii 後台配置獨立子網域的方法

不言
不言原創
2018-07-04 16:27:332369瀏覽

這篇文章主要介紹了關於yii 後台配置獨立子網域的方法,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下

我這裡安裝的是寶塔面板整合的環境WNMP,官網上雖然也有,但是寫的並不明確,對我這種用YII的新手來說也很頭疼,折騰了半天終於弄好,記錄一下。

先解析一個子網域:back.domain.com;

用寶塔面板建立了一個網站,domain.com;

找到Nginx的設定資料夾  conf/ vhost,此文夾中已然存在了一個domain.com.conf 文件,複製一份,重命名為back.domain.com.conf;

domain.com.conf 程式碼:

#START-SITEserver {
    listen 80;
    server_name  yii.com;
    access_log  logs/yii.com.access.log;
    root   D:/wwwroot/yii;
    index  index.php default.php index.html index.htm default.html default.htm;    
    include rewrite/yii.com.conf;
        
    location ~ \.php$ {
        root   D:/wwwroot/yii;
        fastcgi_pass   127.0.0.1:4570;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        include        fastcgi_params;
    }

}#END-SITE

參考YII官網上的介紹https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide-zh-CN/start-installation.md,簡單的修改一下,修改後的back.domain.com.conf 檔案代碼

#START-SITEserver {
    charset utf-8;
    client_max_body_size 128M;

    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6
    server_name back.yii.com;                     ##前台域名
    root        D:/wwwroot/yii/backend/web;   ##这是前台index地址
    index       index.php;    #access_log   D:/wwwroot/yii/access.backend.log main;
    #error_log    D:/wwwroot/yii//error.backend.log;
    location / {        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php?$args;
    }        

    location ~ \.php$ {
        root   D:/wwwroot/yii/backend/web;
        fastcgi_pass   127.0.0.1:4570;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        include        fastcgi_params;
    }    #error_page 404 /404.html;
    location ~ /\.(ht|svn|git) {
        deny all;
    }
}#END-SITE

以上就是本文的全部內容,希望對大家的學習有所幫助,更多相關內容請關注PHP中文網! 

 相關建議:

##Yii1.1框架日誌設定的使用

以上是yii 後台配置獨立子網域的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn