官方文檔:https://hellosean1025.github.io/yapi/devops/index.html
1、環(huán)境要求:
nodejs(7.6+)
mongodb(2.6+)
2、新增目錄并進(jìn)入
mkdir /usr/local/yapi
3、克隆項(xiàng)目;
git clone https://github.com/YMFE/yapi.git vendors //或者下載zip包解壓到 vendors 目錄(clone 整個(gè)倉庫大概 140+ M,可以通過`gitclone --depth=1 https://github.com/YMFE/yapi.git vendors`命令減少,大概 10+ M)
4、復(fù)制配置文件;
cp vendors/config_example.json ./config.json //復(fù)制完成后請(qǐng)修改相關(guān)配置
5、設(shè)置配置文件;
vim?./config.json
內(nèi)容如下:
{
? "port": "3000",
? "adminAccount": "test@163.com",
? "timeout":120000,
? "db": {
? ? "servername": "172.0.0.0",
? ? "DATABASE": "yapi",
? ? "port": 27017,
? ? "user": "yapi",
? ? "pass": "yapi"
? },
? "mail": {
? ? "enable": true,
? ? "host": "smtphm.qiye.163.com",
? ? "port": 465,
? ? "from": "0test@163.com",
? ? "auth": {
? ? ? "user": "test@163.com",
? ? ? "pass": "*******"
? ? }
? }
}
6、編譯并安裝服務(wù);
cd vendors
npm install --production --registry https://registry.npm.taobao.org
npm run install-server //安裝程序會(huì)初始化數(shù)據(jù)庫索引和管理員賬號(hào),管理員賬號(hào)名可在 config.json 配置
7、啟動(dòng)服務(wù);
node server/app.js //啟動(dòng)服務(wù)器后,請(qǐng)?jiān)L問 127.0.0.1:{config.json配置的端口},初次運(yùn)行會(huì)有個(gè)編譯的過程,請(qǐng)耐心等候