一、安装依赖环境
1、安装MongoDB,添加管理员用户,开启auth验证,添加yapi集合及用户
db.createUser({ user: "root", pwd: "xxxxxx", roles: [{ role: "userAdminAnyDatabase", db: "admin" }] })
db.createUser({ user: "yapi", pwd: "xxxxxx", roles: [{ role: "readWrite", db: "yapi" }] })
2、 安装node环境
3、安装yapi
参照官方文档 https://hellosean1025.github.io/yapi/devops/index.html
mkdir yapi
cd yapi
下载 zip 包解压到 vendors 目录
cp vendors/config_example.json ./config.json //复制完成后请修改相关配置
cd vendors
npm install --production --registry https://registry.npm.taobao.org
npm run install-server //安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置
node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候
4、配置nginx
server
{
listen 80;
server_name yapi.xuexi8.net;
location / {
proxy_pass http://localhost:3000;
p