刚刚部署了一下,还不错的项目
安装环境
安装 Node.js,官方安装方法
1 2 3 4 5 6 7 8 9
| curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
curl --silent --location https://rpm.nodesource.com/setup_9.x | sudo bash -
sudo yum -y install nodejs
sudo yum install nodejs npm --enablerepo=epel
|
安装构建工具,要从npm编译和安装本地插件,您可能还需要安装构建工具:
1 2
| sudo yum install gcc-c++ make
|
安装 MongoDB,首先创建源,创建 mongodb.repo
文件
1 2 3 4 5 6 7
|
[mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1
|
yum 安装 MongoDB
1
| sudo yum install mongodb-org
|
为 YApi 初始数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| use yapi db.wong.insert({"name":"kenny wong"}) show dbs db.addUser('yapi','yapi321')
db.createUser( { user: "yapi", pwd: "yapi321", roles: [ { role: "userAdminAnyDatabase", db: "yapi" } ] } )
|
安装YApi
- 创建工程目录
1 2
| mkdir yapi && cd yapi git clone https://github.com/YMFE/yapi.git vendors --depth=1
|
- 修改配置
1 2
| cp vendors/config_example.json ./config.json vi ./config.json
|
配置如下,主要配置 MongoDB 数据库,以及 Admin 账号。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| { "port": "3011", "adminAccount": "admin@admin.com", "db": { "servername": "127.0.0.1", "DATABASE": "yapi", "port": 27017, "user": "yapi", "pass": "yapi123" }, "mail": { "enable": true, "host": "smtp.163.com", "port": 465, "from": "***@163.com", "auth": { "user": "***@163.com", "pass": "*****" } } }
|
- 安装依赖
1 2
| cd vendors npm install --production --registry https://registry.npm.taobao.org
|
- 初始化
1 2 3
| npm run install-server
|
- 启动服务
1 2 3 4
| node server/app.js >> yapi.log 2>&1 &
|
目录结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| | | | | ` ` | | | | | | | | | | | | | | | | | | `
|
Originally posted by @jaywcjlove in https://github.com/YMFE/yapi/issues/103#issuecomment-359669968