安装Node.js环境
wget https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.xz
或者直接浏览器下载传输到服务器上。
https://nodejs.org/zh-cn/download/
tar -xvf node-v14.15.4-linux-x64.tar.xz
太高版本不行,install会报错。16开头的。
配置环境变量
在profile中设置:
vim ~/.bash_profile
#node.js
export NODE_HOME=/realtime/liaoxg/software/nodejs/node-v14.15.4-linux-x64
export PATH=$PATH:$NODE_HOME/bin
source ~/.bash_profile
export是设置环境变量,不用则是bash变量,前者可传输到子进程,后者则不行。
验证
[appuser@host nodejs]npm -v
6.14.10
[appuser@host nodejs]node -v
v14.15.4
npm加速
npm config set registry https://registry.npmmirror.com/
验证:
npm config get registry
安装
直接安装:
npm install -g yapi-cli --registry https://registry.npm.taobao.org
yapi server
离线安装
核心要义在有网络的机器上装好再打包
,而不是在离线机器上安装。网上些都没说清楚这一点。
不过内网连不上,采用命令行部署:
在windows下下载项目再传到linux上:
git clone https://github.com/YMFE/yapi.git vendors
直接用这个老哥的可以:https://blog.csdn.net/w139074301/article/details/117357013
用低版本的node.js和安装包。
unzip vendors.zip
cp vendors/config_example.json ./config.json //复制完成后请修改相关配置npm install --production
yapi的config.json
{"port": "3000","adminAccount": "admin@admin.com","timeout":120000,"db": {"servername": "YOUR IP ADDR","DATABASE": "yapi","port": 27017,"user": "yapi","pass": "yapi","authSource": ""},"mail": {"enable": true,"host": "smtp.163.com","port": 465,"from": "***@163.com","auth": {"user": "***@163.com","pass": "*****"}}
}
yapi-vendor@1.8.5 install-server /realtime/software/yapi/vendors
node server/install.js(node:20720) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
log: mongodb load success…
初始化管理员账号成功,账号名:“admin@admin.com”,密码:“ymfe.org”
后台启动:
nohup node /realtime/software/yapi/vendors/server/app.js >> /realtime/software/yapi/log/webStart.log&
nohup node /cdoc/ dcop//yapi/vendors/server/app.js >> /cdoc/ dcop//yapi/log/webStart.log&
访问地址:部署ip:3000端口,默认的管理员用户名/密码:admin@admin.com/ymfe.org
。