环境准备:
基础环境要求:
nginx+php7.2+mysql+redis
nodejs安装教程:
安装包: 链接:https://pan.baidu.com/s/1ZCatZ2WzQw-ouqJmIhYSWg 提取码:rgfy
composer安装教程:
安装包:链接:https://pan.baidu.com/s/1GoXtcuBzblw5gdkMZCgdSg 提取码:hxlo
使用阿里云镜像
使用阿里云镜像:composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
git安装与使用教程:
安装包:百度云盘:https://pan.baidu.com/s/10ULSP6bnVp-T798hKbtJWA 提取码:sakx
linux系统:
宝塔安装教程:https://www.bt.cn/bbs/thread-19376-1-1.html
windows系统:
upupw集成环境 百度云盘:https://pan.baidu.com/s/1OpJk0M7ltLo7FrQA5iQWew 提取码:unrv
第一步:composer 创建或git下载代码,强烈建议composer创建
composer创建
composer create-project yii-diandi/firetech
git下载
git clone https://gitee.com/wayfiretech_admin/firetech.git
第二步:配置nginx
伪静态配置
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With,Authorization,Content-Type,access-token,bloc-id,store-id;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
接口配置
location /api {
index index.php index.html;
if (!-e $request_filename)
{
rewrite ^/api/(.*)$ /api/index.php last;
}
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
}
后台入口配置
location /backend {
index index.php index.html;
if (!-e $request_filename)
{
rewrite ^/backend/(.*)$ /backend/index.php last;
}
}
完整示例
server
{
listen 80;
listen 443 ssl http2;
server_name demo.hopesfire.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/demo.hopesfire.com/frontend/web;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With,Authorization,Content-Type,access-token,bloc-id,store-id;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate /www/server/panel/vhost/cert/demo.hopesfire.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/demo.hopesfire.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP引用配置,可以注释或修改
include enable-php-72.conf;
#PHP-INFO-END
#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
include /www/server/panel/vhost/rewrite/demo.hopesfire.com.conf;
#REWRITE-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
access_log /dev/null;
}
location /backend {
index index.php index.html;
if (!-e $request_filename)
{
rewrite ^/backend/(.*)$ /backend/index.php last;
}
}
location /api {
index index.php index.html;
if (!-e $request_filename)
{
rewrite ^/api/(.*)$ /api/index.php last;
}
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
}
access_log /www/wwwlogs/demo.hopesfire.com.log;
error_log /www/wwwlogs/demo.hopesfire.com.error.log;
}
第三步:配置数据库
重要!重要!重要!
全局配置文件与console的数据库配置文件内容相同
全局数据库配置文件: common\config\main-local.php
console数据库配置文件:console\config\main-local.php
配置参数内容
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=locai',
'tablePrefix' => 'dd_',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'attributes' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
],
'enableSchemaCache' => true,
// Duration of schema cache.
'schemaCacheDuration' => 3600,
// Name of the cache component used to store schema information
'schemaCache' => 'cache',
],
/* ------ 缓存 ------ **/
'cache' => [
'class' => 'yii\redis\Cache',
],
/* ------ REDIS ------ **/
'redis' => [
'class' => 'yii\redis\Connection',
'hostname' => 'localhost',
'port' => 6379,
'database' => 2,
],
],
'language' => 'zh-CN',
];
第四步:初始化数据库
系统根目录执行
php ./yii migrate/up
第五步:访问系统
小建议,修改为gitee仓库地址,方便后期git更新
git修改远程仓库教程
gitee远程仓库地址:https://gitee.com/wayfiretech_admin/firetech.git
前台地址
http://www.ai.com
后台地址
http://www.ai.com/backend/
接口地址
http://www.ai.com/api/