内网部署YApi

官网地址:https://hellosean1025.github.io/yapi/devops/index.html

环境要求

安装,命令行部署

mkdir yapi
cd yapi
git clone https://github.com/YMFE/yapi.git vendors //或者下载 zip 包解压到 vendors 目录(clone 整个仓库大概 140+ M,可以通过 `git clone --depth=1 https://github.com/YMFE/yapi.git vendors` 命令减少,大概 10+ M)
cp vendors/config_example.json ./config.json //复制完成后请修改相关配置,主要是修改连接mongodb的库名,访问用户名和密码
cd vendors
npm install --production --registry https://registry.npm.taobao.org
npm run install-server //安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置 

# 提示
# 初始化管理员账号成功,账号名:"admin@admin.com",密码:"ymfe.org"

node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候

在执行这一步(npm install --production --registry https://registry.npm.taobao.org)时报错如下:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for dify@1.0.5.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'vendors'
npm ERR! notarget 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-02-07T07_44_03_504Z-debug.log

解决办法:

rm -rf node_modules
npm cache clean --force
rm package-lock.json

服务管理

推荐使用 pm2 管理 node 服务器启动,停止

npm install pm2 -g  //安装pm2
cd  {项目目录} # cd yapi
pm2 start "vendors/server/app.js" --name yapi //pm2管理yapi服务
pm2 info yapi //查看服务信息
pm2 stop yapi //停止服务
pm2 restart yapi //重启服务
上一篇:已解决)'ng' 不是内部或外部命令,也不是可运行的程序或批处理文件


下一篇:循环随机取数组,直到指定数字出现