yapi文档系统centos7部署

官网:https://hellosean1025.github.io/yapi/documents/project.html#%e9%a1%b9%e7%9b%ae%e8%bf%81%e7%a7%bb

官网部署教程:https://hellosean1025.github.io/yapi/devops/index.html#%e9%85%8d%e7%bd%aeldap%e7%99%bb%e5%bd%95

1安装 nodejs 和 Yapi

yum install wget

cd /root
wget https://nodejs.org/dist/v12.18.2/node-v12.18.2-linux-x64.tar.xz

tar -xf node-v12.18.2-linux-x64.tar.xz -C /usr/local/
cd /usr/local/
mv node-v12.18.2-linux-x64/ nodejs/
ll
chown root:root nodejs
cd nodejs
chown root:root * -R
cd bin
ln -s /usr/local/nodejs/bin/* /usr/bin/
npm config set registry https://registry.npm.taobao.org
npm config get registry
npm install -g pm2
npm install -g yapi-cli --registry https://registry.npm.taobao.org
ln -s /usr/local/nodejs/bin/pm2 /usr/bin/
ln -s /usr/local/nodejs/bin/yapi /usr/bin/
ln -s /usr/local/nodejs/bin/yapi-cli /usr/bin/

2安装MongoDB

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.0.tgz
tar zxvf mongodb-linux-x86_64-4.0.0.tgz
mv mongodb-linux-x86_64-4.0.0 /usr/local/mongodb
cd /usr/local/mongodb/
touch mongodb.conf
mkdir db log
chmod 777 db
chmod 777 log

3 下面一段是写入配置

cat <<"EOF" > /usr/local/mongodb/mongodb.conf
port=27017
dbpath= /usr/local/mongodb/db
logpath= /usr/local/mongodb/log/mongodb.log
logappend=true
fork=true
maxConns=100
noauth=true
journal=true
storageEngine=wiredTiger
bind_ip = 0.0.0.0
EOF

3.1 创建软连接

ln -s /usr/local/mongodb/bin/* /usr/bin/

3.2 启动 mongod

mongod --config /usr/local/mongodb/mongodb.conf

4 初始化 Yapi

yapi server   
# 访问 http://127.0.0.1:9090 ,根据页面配置
# 看到页面配置成功后可以 ctrl + c 停止本进程

5启动服务

5.1 如果 mongod 已运行,本条命令可以跳过

mongod --config /usr/local/mongodb/mongodb.conf

5.2 pm2 启动

cd /usr/local/mongodb/my-yapi

pm2 start "vendors/server/app.js" --name yapi

# 访问 http://127.0.0.1:3000,这个端口看初始化的时候配置是哪个就用哪个