Yapi安装配置(CentOs)

环境要求

nodejs(7.6+)

mongodb(2.6+)

git

准备工作

清除yum命令缓存
shell 复制代码
sudo yum clean all
卸载低版本nodejs
shell 复制代码
yum remove nodejs npm -y
安装nodejs,获取资源,安装高版本nodejs
shell 复制代码
curl -sL https://rpm.nodesource.com/setup_8.x | bash -
#安装
sudo yum install -y nodejs
#验证版本
node -v
npm -v
安装Git
shell 复制代码
yum install -y git
安装 mongodb4.0
配置MongoDB的yum源,vi /etc/yum.repos.d/mongodb-org-4.0.repo,添加内容如下:
shell 复制代码
[ngodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/4.0/x86_64/
gpgcheck=0
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
安装MongoDB
shell 复制代码
yum install -y mongodb-org
查看安装路径
shell 复制代码
rpm -ql mongodb-org-server

\^: 注意:官方教程有提到selinux对mongodb会产生负面影响,故选择禁用。vim /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled

修改配置文件,让 MongoDB 在外部也可以访问
shell 复制代码
vim /etc/mongod.conf
#保存后重启服务
service mongod restart
设置开机启动
shell 复制代码
systemctl enable mongod
启动mongodb
shell 复制代码
systemctl start mongod
查看服务状态
shell 复制代码
systemctl status mongod
卸载 MongoDB
shell 复制代码
systemctl disable mongod # 停止开机自启
service mongod stop      # 停止服务
sudo yum erase $(rpm -qa | grep mongodb-org)   # 删除安装包
sudo rm -r /var/log/mongodb     # 删除日志文件
sudo rm -r /var/lib/mongo       # 删除数据文件

YApi 安装

执行安装命令
shell 复制代码
npm install -g yapi-cli --registry https://registry.npm.taobao.org

​ 初始化 YApi ,执行yapi server命令,按提示操作

shell 复制代码
yapi server

​ 在浏览器打开 http://0.0.0.0:9090 访问。 0.0.0.0 替换成指定的域名或ip

将YApi服务放到后台

解决:当shell窗口关闭时,服务也关闭了问题

安装pm2

shell 复制代码
npm install -g pm2 --registry=https://registry.npm.taobao.org

后台启动,关闭

shell 复制代码
# 例如:yapi是安装在/usr/local/yapi/
# 启动执行: 
pm2 start /usr/local/yapi/vendors/server/app.js
# 关闭执行: 
pm2 stop /usr/local/yapi/vendors/server/app.js

检查Yapi是否启动成功

shell 复制代码
ps -ef | grep "yapi"

如果没有服务

shell 复制代码
ps -ef|grep pm2

找到pm2服务然后kill -9杀掉 ,重启yapi

shell 复制代码
pm2 start /usr/local/my-yapi/vendors/server/app.js --name yapi
相关推荐
orion578 小时前
Missing Semester Class1:course overview and introduction of shell
linux
SkyWalking中文站12 小时前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
用户1204872216114 小时前
Linux驱动编译与加载
linux·嵌入式
火车叼位15 小时前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
用户8055336980320 小时前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户8055336980320 小时前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
小猿姐1 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
七歌杜金房1 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
SkyWalking中文站2 天前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维
tntxia2 天前
linux curl命令详解_curl详解
linux