前言导读
平台介绍
官方网站:https://yapi.ymfe.org/index.html
Github地址:https://github.com/YMFE/yapi
特性
安装环境介绍与布署
环境要求(centos安装环境)
nodejs(7.6+)
mongodb(2.6+)
安装 Node.js
[root@tools-server ~]# curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
[root@tools-server ~]# yum -y install nodejs
[root@tools-server ~]# yum install gcc-c++ make -y
安装配置MogoDB数据库
[root@tools-server ~]# cd /etc/yum.repos.d/
[root@tools-server yum.repos.d]# vim mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
[root@tools-server ~]# yum install mongodb-org -y
启动服务
[root@tools-server ~]# service mongod start
Starting mongod (via systemctl): [ 确定 ]
[root@tools-server ~]# ps -ef|grep mongod
mongod 10549 1 0 11:00 ? 00:00:00 /usr/bin/mongod -f /etc/mongod.conf
root 10563 1291 0 11:00 pts/0 00:00:00 grep --color=auto mongod
[root@tools-server ~]# lsof -i :27017
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mongod 10549 mongod 8uIPv4 28721 0t0 TCP localhost:27017 (LISTEN)
创建数据库
[root@tools-server ~]# mongo
MongoDB shell version: 2.6.12
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
> use yapi
switched to db yapi
> db.wong.insert({"name":"kenny wong"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin (empty)
local 0.078GB
yapi 0.078GB
> db.addUser('yapi','yapi321')
WARNING: The 'addUser' shell helper is DEPRECATED. Please use 'createUser' instead
Successfully added user: { "user" : "yapi", "roles" : [ "dbOwner" ] }
安装与配置YApi工具
安装yapi软件
[root@tools-server ~]# mkdir yapi
[root@tools-server ~]# cd yapi/
[root@tools-server yapi]# git clone https://github.com/YMFE/yapi.git vendors
如果下载较慢,可直接下载压缩包进行解压
[root@tools-server yapi-master]# cp config_example.json ../config.json
[root@tools-server yapi-master]# vim config.json
{
"port": "3000",
"adminAccount": "[email protected]",
"db": {
"servername": "127.0.0.1",
"DATABASE": "yapi",
"port": 27017,
"user": "yapi",
"pass": "yapi321"
},
"mail": {
"enable": true,
"host": "smtp.163.com",
"port": 465,
"from": "***@163.com",
"auth": {
"user": "***@163.com",
"pass": "*****"
}
}
}
[root@tools-server yapi-master]# npm install --production --registry https://registry.npm.taobao.org
启动服务
WEB登陆
具体一些后面接口与项目操作,可以参考官方文档