Yapi offline installation tutorial

Official website tutorial

https://hellosean1025.github.io/yapi/devops/index.html

yapi, mongodb, nodejs installation package:

Link: https://pan.baidu.com/s/1kV_hthT8JpvU1GcL2Kg3IQ 
extraction code: u4cc 

Environmental requirements

  • nodei (7.6+)
  • mongodb(2.6+)

Environment construction

Install nodejs

1、解压安装包:
tar -xvf node-v12.13.0-linux-x64.tar.xz 
2.将安装包剪切到/usr/local/目录改名为node
mv node-v12.13.0-linux-x64 /usr/local/node
3.添加node 到环境变量
vi /etc/profile
光标移动到在最后一行 按o插入
export PATH=/usr/local/node/bin:$PATH
按esc :wq 保存退出
4.更新修改内容
[root@localhost ~]# source /etc/profile
5.验证是否安装完成
node -v  输出 v12.13.0
npm -v  输出 6.12.0
至此nodejs 安装完成

 

Install mongodb

1.1 解压MongoDB
[root@localhost ~]# tar -zxvf mongodb-linux-x86_64-3.4.10.tgz
1.2 移动解压文件夹到MongoDB安装目录
[root@localhost ~]# mv mongodb-linux-x86_64-3.4.10 /usr/local/mongodb
1.3 创建MongoDB数据库存放路径
[root@localhost ~]# mkdir -p /data/mongodb/mongodb_data/
1.4 创建MongoDB数据库日志存放路径
[root@localhost ~]# mkdir -p /data/mongodb/mongodb_log/

2.1 启动MongoDB 不做权限验证
[root@localhost ~]# /usr/local/mongodb/bin/mongod --port 27017 --fork --dbpath=/data/mongodb/mongodb_data/ --logpath=/data/mongodb/mongodb_log/mongodb.log --logappend

Note: developer is a folder added at will, does not affect the operation

Enter the MongoDB installation directory

[root@localhost bin]# cd /usr/local/mongodb/
2.2 创建编辑mongodb.conf
[root@localhost mongodb]# vim /usr/local/mongodb/mongodb.conf
插入内容如下
#端口号
port=27017
#数据库路径
dbpath=/data/mongodb/mongodb_data/
#日志输出文件路径
logpath=/data/mongodb/mongodb_log/mongodb.log
pidfilepath=/usr/local/mongodb/mongo.pid
#设置后台运行
fork=true
#日志输出方式
logappend=true
shardsvr=true
#开启认证
#auth=true

:wq 保存退出

2.3添加环境变量
在文本末最后一行添加如下代码:
export PATH=$PATH:/usr/local/mongodb/bin
:wq 保存退出
2.4 使配置立即生效
[root@localhost ~]# source /etc/profile
2.5 验证是否生效,并设置admin库root账号,后面yapi  配置会用到
[root@miguvideo-22 download]# mongo
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.10
Server has startup warnings: 
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] 
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] 
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] 
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] 
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-04-09T19:01:50.145+0800 I CONTROL  [initandlisten] 
> show dbs
admin  0.000GB
local  0.000GB
yapi   0.000GB
> use admin
switched to db admin
>db.createUser({user:'root',pwd:'123456', roles:[{role:'userAdminAnyDatabase', db:'admin'}]})

如果密码已存在使用db.changeUserPassword('root','123456');  修改
至此mongo安装成功
详情安装教程:https://blog.csdn.net/QWERTY55555/article/details/105384602

  Install yapi

3.1 将yapi 文件放入/opt/目录解压到当前目录
 [root@root opt]#tar -xvf yapi.tar 
3.2 新建yapi目录
[root@root opt]#mkdir yapi
3.3 将yapi 解压文件vendors 移动到yapi目录下
[root@root opt]#mv /opt/vendors  /opt/yapi/
3.4复制venders 下 config_example.json改名为config.json到yapi目录下
[root@root opt]#cp /opt/yapi/vendors/config_example.json /opt/yapi/config.json
3.5修改config.json配置ps: port 为yapi端口号,user、pass为mongodb admin数据库 创建的用户名密码这个很重要
[root@root opt]#vi /opt/yapi/config.json
# 配置config.json
{
  "port": "3000",
  "adminAccount": "[email protected]",
  "db": {
    "servername": "127.0.0.1",
    "DATABASE": "yapi",
    "port": 27017,
    "user": "root",
    "pass": "123456",
    "authSource": "admin"
  },
  "mail": {
    "enable": true,
    "host": "smtp.exmail.qq.com",
    "port": 465,
    "from": "[email protected]",
    "auth": {
      "user": "[email protected]",
      "pass": "xxx"
    }
  }
}
# 配置config.json

#初始化数据库
cd /opt/yapi/vendors
npm run install-server

#启动yapi server 后台运行
node /opt/yapi/vendors/server/app.js &

ps:有的时候服务端测试的时候会加载不出报告可以增加内存启动命令如下(内存溢出:FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory。)
node --max-old-space-size=16000 /opt/yapi/vendors/server/app.js &  //单位为MB。设置老生代
node --max-new-space-size=1024 /opt/yapi/vendors/server/app.js & //单位为KB。设置新生代
大小自己改

Browser access to  ip: 3000  yapi interface management platform

The default administrator is [email protected]  password ymfe.org

Published 42 original articles · praised 11 · 20,000+ views

Guess you like

Origin blog.csdn.net/QWERTY55555/article/details/105425897