官网文档地址

项目演示:聊天室地址

记得先换源(一键换源):

bash <(curl -sSL https://img.caoyongzhuo.cn/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh)

一、前提要求

系统要求 内存要求 硬盘要求
Centos7x(别选8) 4G+(8G最好) 20G+(40G最好)
带宽要求 环境要求 软件要求
5Mbps+(10Mbps最好) GIT YARN NVM NODE.JS等 Finalshell(其它SSH软件)

二、环境配置

  • 要运行 Fiora, 你需要 Node.js(推荐 v14 LTS 版本), MongoDB 和 redis

(一)安装nvm、Node.js、yarn

这里推荐使用nvm安装node.js然后使用npm安装yarn

  • 安装nvm

nvm官网

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
或者
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
或者
cd /home
git clone https://github.com/nvm-sh/nvm.git .nvm
cd ~/.nvm
git checkout v0.39.1
. ./nvm.sh
vim ~/.bashrc
将下面的代码输入配置文件
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  • 使用nvm安装node.js
nvm install 14 #使用nvm安装V14.x的node.js
nvm use 14     #启用V14.x的node.js
node -v        #查看node版本
npm -v         #查看npm版本
  • 使用npm安装yarn
npm install -g yarn
yarn --version #查看安装的yarn版本。有版本号就是安装成功。

(二)安装Redis和MongoDB

Redis官网地址 MongoDB官网地址

  • 安装Redis(这里只演示Cenos7的系统。其它系统自行解决。)

1.使用Centos的官网源来安装Redis

sudo yum update  #更新系统源
sudo yum upgrade #升级软件包
sudo yum insatll redis #安装redis

2.从 Snapcraft 安装Redis(替代方案)

sudo yum install epel-release
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install redis

3.设置开机启动Redis

sudo vim /usr/lib/systemd/system/redis.service

添加下面的内容到配置文件
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload #保存并退出,执行这句话
sudo systemctl start redis.service #启动服务
sudo systemctl enable redis.service #设置开机自启动
  • 安装MongoDB(这里只演示Cenos7的系统。其它系统自行解决。)

1.配置包管理系统

vim /etc/yum.repos.d/mongodb-org-5.0.repo #编辑软件源,并添加下面的内容
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc

2.安装 MongoDB 包

sudo yum install -y mongodb-org

3.请将以下exclude指令添加到您的/etc/yum.conf文件中

exclude=mongodb-org,mongodb-org-database,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

4.启动 MongoDB

sudo systemctl daemon-reload
sudo systemctl start mongod
sudo systemctl status mongod #验证MongoDB状态

三、安装Fiora主程序

  • 下载主程序文件。
#作者的原始版本
git clone https://github.com/yinxin630/fiora.git -b master
#我自己的修改版(修改了有些BUG)
git clone https://github.com/TonaSmith/fiora_signed
  • 进入到安装目录安装依赖
cd fiora
yarn install
  • 构建客户端代码并配置 JwtSecret
yarn build:web
echo "JwtSecret=<string>" > .env2 #要将 <string> 替换为一个秘密文本
  • 启动服务端
yarn start

使用浏览器打开 http://[ip地址]:[端口](比如 http://127.0.0.1:9200)

  • 使用 yarn start 运行服务端会在断开 ssh 连接后停止运行, 推荐使用 pm2 来运行
# 安装 pm2
npm install -g pm2
# 使用 pm2 运行 fiora
pm2 start yarn --name fiora -- start
# 查看 pm2 应用状态
pm2 ls
# 查看 pm2 fiora 日志
pm2 logs fiora

四、域名反代

  • 在宝塔面板中新建网站
  • 然后配置HTTPS(SSL证书)
  • 打开配置文件,将文件内容替换为如下内容
  • chat.caoyongzhuo.cn换为自己的网站地址
server
{
    listen 80;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    listen [::]:80;
    server_name chat.caoyongzhuo.cn;
    root /www/wwwroot/chat.caoyongzhuo.cn;
    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #HTTP_TO_HTTPS_START
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #HTTP_TO_HTTPS_END
    ssl_certificate    /www/server/panel/vhost/cert/chat.caoyongzhuo.cn/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/chat.caoyongzhuo.cn/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;
location / {
    proxy_pass http://127.0.0.1:9200;
    proxy_set_header Host             $host;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forward-Proto http;
    proxy_set_header X-Nginx-Proxy true;
    proxy_http_version 1.1;
    proxy_redirect off;
}
    include enable-php-71.conf;
    #PHP-INFO-END
    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/chat.caoyongzhuo.cn.conf;
    #REWRITE-END
    access_log  /www/wwwlogs/chat.caoyongzhuo.cn.log;
    error_log  /www/wwwlogs/chat.caoyongzhuo.cn.error.log;
}

五、搭建中遇到的问题

  • 启动yarn install时候遇到“权限不够的问题”

这是由于nvm的node目录对Fiora主程序目录进行请求时用户组不是root原因导致的。解决办法:

#进入宝塔面板 /www/wwwroot/自己的网站
例如:/www/wwwroot/chat.caoyongzhuo.cn
#将chat.caoyongzhuo.cn整个文件夹的权限从www改为root即可
  • 启动yarn install报错

很有可能是node的版本低于14导致的。解决办法:

nvm install 15 #使用nvm安装node v.15 版本
nvm use 15     #使用nvm启动node v.15 版本
yarn insatll   #重新安装依赖
  • 第二次运行yarn start或者pm2 start yarn --name fiora -- start时失败

这是由于9200端口被占用导致的。解决办法:

sudo lsof -i :9200 #查看端口9200下的程序pid号
sudo kill -9 31363 #杀死该pid。如31362
yarn start 或者 pm2 start yarn --name fiora -- start #重新运行即可
  • PM2管理器中有多个fiora项目

这是由于多次运行pm2 start yarn --name fiora -- start导致的。解决办法:

pm2 delete all #删除所有项目
pm2 start yarn --name fiora -- start #重新创建fiora项目
pm2 retart fiora #重新启动fiora项目
pm2 ls #查看运行中的项目
pm2 save #保证重启VPS时候pm2也自启动

项目演示:聊天室地址

创建 GitHub Action 动作并复制以下命令

name: image
on:
  pull_request:
    paths:
      - 'static/**'
jobs:
  compress:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
      - uses: namoscato/action-tinify@v1
        with:
          api_key: ${{ secrets.TINIFY_API_KEY }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
input description
api_key Tinify API key (create one here)
github_token GITHUB_TOKEN秘密

一、代码如下

import turtle as t
import math

# 设置速度
t.speed(100)  # 速度
t.delay(10)  # 延迟
# turtle.tracer(False)
# 双耳
# 左耳
t.penup()
t.goto(-150, 200)
t.setheading(160)
t.begin_fill()
t.pendown()
t.circle(-30, 230)
t.setheading(180)
t.circle(37, 90)
t.end_fill()
# 右耳
t.penup()
t.goto(60, 200)
t.setheading(20)
t.begin_fill()
t.pendown()
t.circle(30, 230)
t.setheading(0)
t.circle(-37, 90)
t.end_fill()
# 头
t.pensize(5)
t.penup()
t.goto(-113, 237)
t.setheading(30)
t.pendown()
t.circle(-134, 60)

t.penup()
t.goto(-150, 200)
t.setheading(-120)
t.pendown()
t.circle(200, 80)

t.penup()
t.goto(60, 200)
t.setheading(-60)
t.pendown()
t.circle(-200, 80)

t.penup()
t.setheading(210)
t.pendown()
t.circle(-120, 60)
# 双眼
# 左眼
# 眼圈
t.penup()
t.goto(-140, 100)
t.setheading(-45)
t.begin_fill()
t.pendown()
a = 0.2
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.1
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a - 0.1
        t.lt(3)
        t.fd(a)
t.end_fill()
# 眼白
t.fillcolor("white")
t.penup()
t.goto(-103, 125)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(13, 360)
t.end_fill()
# 眼珠
t.fillcolor("sienna")
t.pencolor("sienna")
t.penup()
t.goto(-102, 133)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(5, 360)
t.end_fill()
# 右眼
# 眼圈
t.penup()
t.goto(50, 100)
t.setheading(45)
t.fillcolor("black")
t.pencolor("black")
t.begin_fill()
t.pendown()
a = 0.2
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.1
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a - 0.1
        t.lt(3)
        t.fd(a)
t.end_fill()
# 眼白
t.fillcolor("white")
t.penup()
t.goto(13, 125)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(13, 360)
t.end_fill()
# 眼珠
t.fillcolor("sienna")
t.pencolor("sienna")
t.penup()
t.goto(12, 133)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(5, 360)
t.end_fill()
# 鼻子
t.pencolor("black")
t.fillcolor("black")
t.penup()
t.goto(-55, 133)
t.begin_fill()
t.pendown()
t.fd(20)
t.seth(-120)
t.fd(20)
t.seth(120)
t.fd(20)
t.end_fill()
# 嘴
t.penup()
t.goto(-70, 110)
t.setheading(-30)
t.fillcolor("red")
t.begin_fill()
t.pendown()
t.circle(50, 60)
t.setheading(-120)
t.circle(-100, 15)
t.circle(-15, 90)
t.circle(-100, 15)
t.end_fill()
# 四肢
# 左臂
t.penup()
t.goto(-175, 100)
t.fillcolor("black")
t.begin_fill()
t.setheading(-120)
t.pendown()
t.fd(100)
t.setheading(-110)
t.circle(20, 180)
t.fd(30)
t.circle(-5, 160)
t.end_fill()
# 右臂
t.penup()
t.goto(85, 100)
t.setheading(60)
t.begin_fill()
t.pendown()
t.fd(100)
t.setheading(70)
t.circle(20, 180)
t.fd(30)
t.circle(-5, 160)
t.end_fill()
# 小红心
t.penup()
t.pencolor("red")
t.fillcolor('red')
t.goto(105, 200)
t.begin_fill()
t.pendown()
t.circle(-5, 180)
t.setheading(90)
t.circle(-5, 180)
t.setheading(-120)
t.fd(17)
t.penup()
t.goto(105, 200)
t.pendown()
t.setheading(-60)
t.fd(17)
t.end_fill()
t.pencolor("black")
t.fillcolor("black")
# 左腿
t.penup()
t.goto(-120, -45)
t.begin_fill()
t.pendown()
t.setheading(-90)
t.circle(-140, 20)
t.circle(5, 109)
t.fd(30)
t.circle(10, 120)
t.setheading(90)
t.circle(-140, 10)
t.end_fill()
# 右腿
t.penup()
t.goto(30, -45)
t.begin_fill()
t.pendown()
t.setheading(-90)
t.circle(140, 20)
t.circle(-5, 109)
t.fd(30)
t.circle(-10, 120)
t.setheading(90)
t.circle(140, 10)
t.end_fill()
# 冰糖外壳
t.pensize(1)
t.penup()
t.goto(-160, 195)
t.setheading(160)
t.pendown()
t.circle(-40, 230)
t.setheading(30)
t.circle(-134, 58)
t.setheading(60)
t.circle(-40, 215)
t.setheading(-60)
t.fd(15)
t.circle(2, 200)
t.setheading(65)
t.fd(30)
t.circle(-25, 180)
t.fd(100)
t.circle(2, 25)
t.circle(-200, 47)
t.circle(2, 60)
t.circle(140, 23)
t.circle(-2, 90)
t.setheading(180)
t.fd(70)
t.circle(-2, 90)
t.fd(30)
t.setheading(-160)
t.circle(-100, 35)
t.setheading(-90)
t.fd(30)
t.circle(-2, 90)
t.fd(70)
t.circle(-2, 90)
t.setheading(60)
t.circle(140, 30)
t.circle(2, 45)
t.circle(-200, 19)
t.circle(2, 130)
t.fd(30)
t.circle(-25, 180)
t.fd(100)
t.setheading(90)
t.circle(-200, 30)
# 冰糖面罩
t.pensize(3)
t.penup()
t.goto(65, 120)
t.setheading(90)
t.pendown()
t.pencolor("red")
a = 1
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:  # 控制a的变化
        a = a + 0.25
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a - 0.25
        t.lt(3)
        t.fd(a)
t.pencolor("orange")
t.penup()
t.goto(66, 120)
t.pendown()
a = 1
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.255
        t.lt(3)
        t.fd(a)
    else:
        a = a - 0.255
        t.lt(3)
        t.fd(a)
t.pencolor("green")
t.penup()
t.goto(67, 120)
t.pendown()
a = 1
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.2555
        t.lt(3)
        t.fd(a)
    else:
        a = a - 0.2555
        t.lt(3)
        t.fd(a)
t.pencolor("deep sky blue")
t.penup()
t.goto(68, 120)
t.pendown()
a = 1
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.25955
        t.lt(3)
        t.fd(a)
    else:
        a = a - 0.25955
        t.lt(3)
        t.fd(a)
t.pencolor("pink")
t.penup()
t.goto(71, 120)
t.pendown()
a = 1
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.26
        t.lt(3)
        t.fd(a)
    else:
        a = a - 0.26
        t.lt(3)
        t.fd(a)
t.pencolor("purple")
t.penup()
t.goto(72, 120)
t.pendown()
a = 1
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.269
        t.lt(3)
        t.fd(a)
    else:
        a = a - 0.269
        t.lt(3)
        t.fd(a)

# 五环
t.penup()
t.goto(-55, -10)
t.pendown()
t.pencolor("blue")
t.circle(10)
t.penup()
t.goto(-40, -10)
t.pendown()
t.pencolor("black")
t.circle(10)
t.penup()
t.goto(-25, -10)
t.pendown()
t.pencolor("red")
t.circle(10)
t.penup()
t.goto(-50, -20)
t.pendown()
t.pencolor("yellow")
t.circle(10)
t.penup()
t.goto(-30, -20)
t.pendown()
t.pencolor("green")
t.circle(10)

t.done()

二、一键执行文件

有些同学不会使用Python。我在这里打包了exe程序文件,双击执行即可。
下载地址:冰墩墩一键执行文件

文章地址:查看原文

一、服务器部署宝塔面板

二、安装源代码

下载地址: V1.0

三、修改代码

为了防止抓拍的照片被清除覆盖,需要修改源代码

注释掉11行代码
// echo '确定清空所有照片?<br /><br />';

注释掉41行代码
//echo "<a href=?page=$page&id=$id&type=del>清空所有照片</a> <br /><br />";

四、部署完成

(官方)体验地址:猪头官方
(本站)体验地址:本站官方

说明:猪头官方地址使用者较多,个人测试数据不一定安全。本站官网服务器数据独立可靠,安全系数高。请读者自行判定使用哪种渠道测试。

游戏体验地址:人生重开模拟器

一、安装GIT工具

上文已经记录了Centos8安装Git的完整过程,这里不再赘述。

二、下载源代码

代码地址:人生重开模拟器

[root@C20210805207038 home]# git clone https://github.com/AliyunWorkbench/lifeRestart.git

正克隆到 'lifeRestart'...
remote: Enumerating objects: 112, done.
remote: Counting objects: 100% (50/50), done.
remote: Compressing objects: 100% (40/40), done.
remote: Total 112 (delta 20), reused 10 (delta 10), pack-reused 62
接收对象中: 100% (112/112), 791.09 KiB | 4.82 MiB/s, 完成.
处理 delta 中: 100% (31/31), 完成.

三、安装npm

[root@C20210805207038 lifeRestart]# sudo yum module install nodejs

上次元数据过期检查:0:22:31 前,执行于 2022年02月12日 星期六 13时29分50秒。
依赖关系解决。
===========================================================================================================================================================
 软件包                           架构                   版本                                                              仓库                       大小
===========================================================================================================================================================
安装组/模块包:
 nodejs                           x86_64                 1:10.24.0-1.module_el8.3.0+717+fa496f1d                           AppStream                 8.8 M
 npm                              x86_64                 1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d                 AppStream                 3.7 M
安装弱的依赖:
 nodejs-full-i18n                 x86_64                 1:10.24.0-1.module_el8.3.0+717+fa496f1d                           AppStream                 7.3 M
安装模块配置档案:
 nodejs/common                                                                                                                                            
启用模块流:
 nodejs                                                  10                                                                                               

事务概要
===========================================================================================================================================================
安装  3 软件包

总下载:20 M
安装大小:71 M
确定吗?[y/N]: y
下载软件包:
(1/3): npm-6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64.rpm                                                      388 kB/s | 3.7 MB     00:09    
(2/3): nodejs-full-i18n-10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64.rpm                                                   443 kB/s | 7.3 MB     00:16    
(3/3): nodejs-10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64.rpm                                                             501 kB/s | 8.8 MB     00:18    
-----------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                       1.1 MB/s |  20 MB     00:18     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  运行脚本: npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64                                                                               1/1 
  准备中  :                                                                                                                                            1/1 
  安装    : nodejs-full-i18n-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                            1/3 
  安装    : npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64                                                                               2/3 
  安装    : nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                                      3/3 
  运行脚本: nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                                      3/3 
  验证    : nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                                      1/3 
  验证    : nodejs-full-i18n-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                            2/3 
  验证    : npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64                                                                               3/3 

已安装:
  nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                      nodejs-full-i18n-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64              
  npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64              

完毕!

四、在源代码目录安装依赖

[root@C20210805207038 lifeRestart]# npm install

> core-js@3.21.0 postinstall /home/lifeRestart/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js:
> https://opencollective.com/core-js 
> https://patreon.com/zloirock 
> https://paypal.me/zloirock 
> bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for webpack-dev-server@4.7.4: wanted: {"node":">= 12.13.0"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: webpack-dev-server@4.7.4
npm WARN notsup Unsupported engine for http-proxy-middleware@2.0.3: wanted: {"node":">=12.0.0"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: http-proxy-middleware@2.0.3
npm WARN notsup Unsupported engine for open@8.4.0: wanted: {"node":">=12"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: open@8.4.0
npm WARN notsup Unsupported engine for schema-utils@4.0.0: wanted: {"node":">= 12.13.0"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: schema-utils@4.0.0
npm WARN notsup Unsupported engine for strip-ansi@7.0.1: wanted: {"node":">=12"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: strip-ansi@7.0.1
npm WARN notsup Unsupported engine for webpack-dev-middleware@5.3.1: wanted: {"node":">= 12.13.0"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: webpack-dev-middleware@5.3.1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN notsup Unsupported engine for ansi-regex@6.0.1: wanted: {"node":">=12"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: ansi-regex@6.0.1
npm WARN notsup Unsupported engine for schema-utils@4.0.0: wanted: {"node":">= 12.13.0"} (current: {"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: schema-utils@4.0.0
npm WARN xlsx_transform@ No repository field.
npm WARN xlsx_transform@ No license field.

added 511 packages from 331 contributors and audited 512 packages in 32.109s

53 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

五、编译打包

[root@C20210805207038 lifeRestart]# npm run build

> xlsx_transform@ build /home/lifeRestart
> webpack --mode production && cp -r ./view/* ./public/ && cp -r ./data ./public/ && mv public build

asset bundle.js 783 KiB [emitted] [minimized] [big] (name: main)
orphan modules 85.9 KiB [orphan] 8 modules
runtime modules 221 bytes 1 module
modules by path ./node_modules/core-js/internals/*.js 118 KiB
  ./node_modules/core-js/internals/to-string-tag-support.js 210 bytes [built] [code generated]
  ./node_modules/core-js/internals/well-known-symbol.js 1.03 KiB [built] [code generated]
  ./node_modules/core-js/internals/global.js 590 bytes [built] [code generated]
  + 151 modules
modules by path ./node_modules/core-js/modules/*.js 70.8 KiB
  ./node_modules/core-js/modules/es.object.to-string.js 380 bytes [built] [code generated]
  ./node_modules/core-js/modules/es.promise.js 14 KiB [built] [code generated]
  ./node_modules/core-js/modules/web.dom-collections.for-each.js 887 bytes [built] [code generated]
  ./node_modules/core-js/modules/es.array.iterator.js 2.45 KiB [built] [code generated]
  + 31 modules
./src/index.js + 8 modules 87.8 KiB [built] [code generated]
./node_modules/regenerator-runtime/runtime.js 24.3 KiB [built] [code generated]

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets: 
  bundle.js (783 KiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  main (783 KiB)
      bundle.js

WARNING in webpack performance recommendations: 
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/

webpack 5.68.0 compiled with 3 warnings in 6764 ms

六、检查文件编译情况

[root@C20210805207038 lifeRestart]# ls
bitcoin:  build.sh  _config.yml     data      _layouts  node          package.json       README.md  src   utils  webpack.config.cjs
build     CNAME     core-js@3.21.0  index.md  LICENSE   node_modules  package-lock.json  repl       test  view   yarn.lock

[root@C20210805207038 lifeRestart]# cd build

[root@C20210805207038 build]# ls
bundle.js            dark.css  iconfont.ttf   iconfont.woff2  index.html  manifest.json  test.html
condition_test.html  data      iconfont.woff  images          light.css   sw.js

出现了build文件夹,说明编译完成。

七、将build文件部署为站点

运行如下代码,站点即为 localhost:5000(临时使用)

npm run build
npm run preview

http-serve部署(长期部署)

npm install http-server -g
dist目录下运行 http-server -p 5000

Starting up http-server, serving ./public

http-server version: 14.1.0

http-server settings: 
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://127.0.0.1:8080
  http://10.10.155.2:8080
Hit CTRL-C to stop the server

八、开放相应端口

查看防火墙某个端口是否开放
firewall-cmd --query-port=3306/tcp
开放防火墙端口3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
注意:开放端口后要重启防火墙生效
重启防火墙
systemctl restart firewalld
关闭防火墙端口
firewall-cmd --remove-port=3306/tcp --permanent
查看防火墙状态
systemctl status firewalld
关闭防火墙
systemctl stop firewalld
打开防火墙
systemctl start firewalld
开放一段端口
firewall-cmd --zone=public --add-port=40000-45000/tcp --permanent
查看开放的端口列表
firewall-cmd --zone=public --list-ports
查看被监听(Listen)的端口
netstat -lntp
检查端口被哪个进程占用
netstat -lnp|grep 3306