这篇文章主要介绍了关于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中文网!
相关推荐:
以上就是yii 后台配置独立子域名的方法的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号