centos安裝yapi作為mock服務(wù)

官方文檔: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)耐心等候

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容