YApi官网:https://hellosean1025.github.io/yapi/
安装 nodejs 和 Yapi
代码语言:javascript复制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/
安装MongoDB
代码语言:javascript复制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
# 下面一段是写入配置
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
# 创建软连接
ln -s /usr/local/mongodb/bin/* /usr/bin/
# 启动 mongod
mongod --config /usr/local/mongodb/mongodb.conf
初始化 Yapi
代码语言:javascript复制yapi server
# 访问 http://127.0.0.1:9090 ,根据页面配置
# 看到页面配置成功后可以 ctrl c 停止本进程
启动服务
代码语言:javascript复制# 如果 mongod 已运行,本条命令可以跳过
mongod --config /usr/local/mongodb/mongodb.conf
# pm2 启动
cd /usr/local/mongodb/my-yapi
pm2 start "vendors/server/app.js" --name yapi
# 访问 http://127.0.0.1:3000,这个端口看初始化的时候配置是哪个就用哪个