安装node:
安装mongodb:
官方安装方式:
npm install -g yapi-cli --registry https://registry.npm.taobao.org yapi server
方式一:
https://cdn.npmmirror.com/packages/yapi-vendor/1.12.0/yapi-vendor-1.12.0.tgz
方式二:
通过git下载,可下载最新或指定分支,创建yapi目录,进入目录clone代码到vendors
git clone vendors
安装扩展
npm install --production --registry https://registry.npmmirror.com
如果扩展安装因证书问题可以增加 --force参数
初始化:
拷贝vendors目录下配置示例文件到yapi目录
cp config_example.json ../config.json
根据自己情况修改配置文件内容:
{ "port": "3000", "adminAccount": "admin@admin.com", "timeout":120000, "db": { "servername": "127.0.0.1", "DATABASE": "yapi", "port": 27017, "user": "test1", "pass": "test1", "authSource": "" }, "mail": { "enable": true, "host": "smtp.163.com", "port": 465, "from": "***@163.com", "auth": { "user": "***@163.com", "pass": "*****" } } } ~
配置文件中禁止注册,增加:
"closeRegister":true,
配置文件修改完成后,进入vendor目录,启动服务
node server/app.js
后台服务启动
node server/app.js &
location /{ proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:3000; client_max_body_size 512m; proxy_connect_timeout 600000; proxy_send_timeout 600000; proxy_read_timeout 600000; }
资源访问如果有问题修改以内内容:
location ~ .*\.(js|css)?$ { proxy_pass http://127.0.0.1:3000; expires 12h; }
安装
sudo npm i pm2 -g
启动
pm2 start server/app.js
其它命令
pm2 info yapi //查看服务信息 pm2 stop yapi //停止服务 pm2 restart yapi //重启服务