Install YAPI under Linux

Current virtual machine: CentOS 8

1 Install dependent software

YAPI installation environment requirements:

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

1.1 Install NodeJS

# 下载压缩包wget https://npm.taobao.org/mirrors/node/v14.4.0/node-v14.4.0-linux-x64.tar.xz # 创建文件夹mkdir -p /usr/local/lib/nodejs # 解压到文件夹tar -xJvf node-v14.4.0-linux-x64.tar.xz -C /usr/local/lib/nodejs  # 修改环境变量vi /etc/profile# 最后一行加入export PATH=/usr/local/lib/nodejs/node-v14.4.0-linux-x64/bin:$PATH # 使环境变量生效source /etc/profile # 验证是否安装好node -v

1.2 MongoDB

MongoDB: Distributed document database.

1.2.1 Install MongoDB

Download link: https://www.mongodb.com/download-center/community/releases/archive

mkdir /usr/local/mongodbcd /usr/local/mongodb # 1.下载MongoDB压缩包wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.23.tgz # 2.解压tar -xvzf mongodb-linux-x86_64-4.0.23.tgz # 3.修改环境变量vi /etc/profile# 在最后一行加入export PATH=/usr/local/mongodb/mongodb-linux-x86_64-4.0.23/bin:$PATH # 使环境变量生效source /etc/profile

1.2.2 Run MongoDB

# 1.创建默认数据目录(需要确保当前用户具有该目录的读写权限)mkdir -p /data/db # 2.运行mongodb,使用默认数据目录(--dbpath /data/db)cd /usr/local/mongodb/mongodb-linux-x86_64-4.0.23nohup mongod & # 3.查看是否启动成功tail -200f nohuo.out # 看到如下日志表示启动成功# 日期时间 NETWORK  [initandlisten] waiting for connections on port 27017

1.2.3 Create a yapi database

Use the MongoDB shell tool mongo to create a database:

[[email protected] ~]# mongoMongoDB shell version v4.0.23connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodbImplicit session: session { "id" : UUID("6e0b0db5-833a-4317-8b0f-b5cac9b9b097") }MongoDB server version: 4.0.23Server has startup warnings: 2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] 2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] 2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.2021-06-03T21:44:35.490+0800 I CONTROL  [initandlisten] 2021-06-03T21:44:35.491+0800 I CONTROL  [initandlisten] 2021-06-03T21:44:35.491+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.2021-06-03T21:44:35.491+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'2021-06-03T21:44:35.491+0800 I CONTROL  [initandlisten] 

Enter use yapi to create a yapi database:

> use yapiswitched to db yapi

2 Install YAPI

2.1 Start the YAPI visual deployment program

# 1.npm安装yapi-clinpm install -g yapi-cli --registry https://registry.npm.taobao.org # 2.启动yapi安装程序yapi server # 会打印出如下日志:# 在浏览器打开 http://0.0.0.0:9090 访问。非本地服务器,请将 0.0.0.0 替换成指定的域名或ip 

2.2 Visual deployment

Visit http://172.22.195.68:9090/ , fill in the following information and click the "Start Deployment" button:

image.png

Then the "Deployment Log" window will pop up:

image.png

2.3 Start YAPI

Execute node/{website path/server/app.js} to start:

cd /usr/local/yapinode vendors/server/app.js

2.4 Log in to YAPI

The access port configured on the front end is 3000, so the access address is http://172.22.195.68:3000/ :

image.png
If you cannot access, please consider whether it is caused by firewall blocking. I am a local virtual machine here, so I first turn off the firewall.
Never turn off the fireproof paint during production! ! !
systemctl stop firewalld.service

The previously configured administrator account is [email protected], and the default password is ymfe.org. Log in and you can play:

image.png

reference

1.[YAPI intranet deployment]( https://hellosean1025.github.io/yapi/devops/index.html )

2.[MongoDB official installation document]( https://docs.mongodb.com/guides/server/install/ )