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 ![image-20220705092249767](https://file.jishuzhan.net/article/1742863317925367809/552da8157714c9ab995bc3f3daeac187.webp) ###### 修改配置文件,让 MongoDB 在外部也可以访问 ```shell vim /etc/mongod.conf #保存后重启服务 service mongod restart ``` ![image-20220705092919461](https://file.jishuzhan.net/article/1742863317925367809/fd5740b76d4a8660bed3238a418255a1.webp) ###### 设置开机启动 ```shell systemctl enable mongod ``` ###### 启动mongodb ```shell systemctl start mongod ``` ###### 查看服务状态 ```shell systemctl status mongod ``` ![image-20220705092420127](https://file.jishuzhan.net/article/1742863317925367809/1fae0637810b6fbe509e2f5dfff64c9c.webp) ###### 卸载 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 ![在这里插入图片描述](https://file.jishuzhan.net/article/1742863317925367809/0fb633c850a89e3c451b0c66af1c65b0.webp) * ###### 将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" ``` ![image-20220705093835975](https://file.jishuzhan.net/article/1742863317925367809/5565da19ffe058869751d657c86f9315.webp) 如果没有服务 ```shell ps -ef|grep pm2 ``` 找到pm2服务然后kill -9杀掉 ,重启yapi ```shell pm2 start /usr/local/my-yapi/vendors/server/app.js --name yapi ```

相关推荐
平生不喜凡桃李27 分钟前
Linux网络:UDP
linux·网络·udp
weixiao04301 小时前
Linux网络 网络层
linux·网络·智能路由器
从零开始的ops生活2 小时前
【Day 80】Linux-NAS 和 SAN 存储
linux·运维·php
Wang's Blog2 小时前
Linux小课堂: 输入重定向与管道操作详解
linux·运维·服务器
迎風吹頭髮3 小时前
Linux内核架构浅谈49-Linux per-CPU页面缓存:热页与冷页的管理与调度优化
linux·缓存·架构
jason.zeng@15022073 小时前
centos中安装redis
linux·redis·centos
w23617346014 小时前
Linux 服务器安全巡检与加固:从命令到实操(CentOS/Ubuntu 通用)
linux·服务器·安全·安全加固·安全巡检
xiaogg36784 小时前
阿里云k8s1.33部署yaml和dockerfile配置文件
java·linux·kubernetes
python百炼成钢4 小时前
3.Linux 网络相关
linux·运维·网络·stm32·单片机