yii 後臺配置獨立子域名方法

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

首先解析一個子域名:back.domain.com;html

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

找到Nginx的配置文件夾  conf/vhost,此文夾中已然存在了一個domain.com.conf 文件,複製一份,重命名爲back.domain.com.conf;github

domain.com.conf 代碼:web

#START-SITE
server { 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 文件代碼yii2

#START-SITE
server { 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
相關文章
相關標籤/搜索