记一次 Centos7.x 安装、部署 easy-mock 服务(基于 Node、MongoDB、Redis 环境)

在这里插入图片描述

一、基本信息

官网 https://easymock.org/
官方教程 https://easymock.org/getting-started.html
api https://easymock.org/api/
github https://github.com/easymock/easymock

二、安装 easy-mock 前准备

1、Nodejs环境安装
参考 https://blog.csdn.net/llwy1428/article/details/111880286
其他参考 官网

sudo yum install gcc-c++ make
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum -y install nodejs

2、安装部署 MongoDB 数据库
(1)参考此文中的第四步
https://blog.csdn.net/llwy1428/article/details/113408974

(2)或参考 Centos7.2 x64 安装 MongoDb 4.0
https://blog.csdn.net/llwy1428/article/details/93462075
3、Redis 数据库安装部署
参考
(1)Centos7.2 搭建 Redis v5.0-单机版-伪集群 https://blog.csdn.net/llwy1428/article/details/93659772
(2)Centos7.x 安装配置 Redis 6.0.5 并配置主从复制 https://blog.csdn.net/llwy1428/article/details/106730436
(3)Centos7.2 安装单机版 Redis 5.0 (编译安装) https://blog.csdn.net/llwy1428/article/details/93612187

三、easy-mock 安装部署

1、git下载 easy-mock

[root@master ~]# git clone https://github.com/easy-mock/easy-mock.git

2、进入 easy-mock

[root@master ~]# cd easy-mock
[root@master easy-mock]# ll
总用量 636
-rwxr-xr-x  1 root root   2056 1月  31 01:37 app.js
drwxr-xr-x  2 root root    155 1月  31 01:37 build
-rwxr-xr-x  1 root root   9444 1月  31 01:37 CHANGELOG.md
drwxr-xr-x  2 root root     26 2月   1 17:42 config
drwxr-xr-x  2 root root    121 1月  31 01:37 controllers
drwxr-xr-x  2 root root   4096 2月   1 17:18 dist
-rwxr-xr-x  1 root root     79 1月  31 01:37 jest.config.js
-rwxr-xr-x  1 root root  35051 1月  31 01:37 LICENSE
drwxr-xr-x  2 root root     37 1月  31 01:37 middlewares
drwxr-xr-x  2 root root    174 1月  31 01:37 models
-rwxr-xr-x  1 root root   3998 1月  31 01:37 package.json
-rwxr-xr-x  1 root root 555541 1月  31 01:39 package-lock.json
drwxr-xr-x  2 root root    151 1月  31 01:37 proxy
drwxr-xr-x  3 root root     36 1月  31 01:37 public
-rwxr-xr-x  1 root root  12051 1月  31 01:37 README.md
-rwxr-xr-x  1 root root  11522 1月  31 01:37 README.zh-CN.md
-rwxr-xr-x  1 root root   1882 1月  31 01:37 router-config.js
drwxr-xr-x  6 root root    101 1月  31 01:37 test
drwxr-xr-x  2 root root     87 1月  31 01:37 util
drwxr-xr-x 10 root root    177 1月  31 01:40 views

3、进入 easy-mock 的配置文件目录

[root@master easy-mock]# cd config/

4、编辑默认的配置文件

[root@master easy-mock]# vim config/default.json

5、编辑内容

{
  "port": 7300,//服务端口
  "host": "0.0.0.0",//允许本服务器以外的地址访问
  "pageSize": 30,
  "proxy": false,
  "db": "mongodb://【MongoDB 数据库 IP】/easy-mock",
  "unsplashClientId": "",
  "redis": {
    "keyPrefix": "[Easy Mock]",
    "port": 6379,
    "host": "【Redis 数据库 IP】",
    "password": "【Redis 密码】",
    "db": 0
  },
  "blackList": {
    "projects": [],
    "ips": []
  },
  "rateLimit": {
    "max": 1000,
    "duration": 1000
  },
  "jwt": {
    "expire": "14 days",
    "secret": "shared-secret"
  },
  "upload": {
    "types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
    "size": 5242880,
    "dir": "../public/upload",
    "expire": {
      "types": [".json", ".yml", ".yaml"],
      "day": -1
    }
  },
  "ldap": {
    "server": "",
    "bindDN": "",
    "password": "",
    "filter": {
      "base": "",
      "attributeName": ""
    }
  },
  "fe": {
    "copyright": "",
    "storageNamespace": "easy-mock_",
    "timeout": 25000,
    "publicPath": "/dist/"
  }
}

6、对目录赋权

[root@master ~]# chmod -R 755 easy-mock

7、配置启动
(1)控制台启动

[root@master easy-mock]# node app.js

(2)后台启动 (使用PM2启动 PM2安装部署参考:https://blog.csdn.net/llwy1428/article/details/113487584

[root@master easy-mock]# pm2 start app.js

四、浏览器查看、操作

地址栏录入 http://【easy-mock 服务器 IP 】:7300/login
登录页
选择“简体中文”点击“OK”
在这里插入图片描述
点击“开始吧”
在这里插入图片描述
出现登录窗口
录入用户名、密码会自动注册
在这里插入图片描述
登录后首页(有一个演示项目)
在这里插入图片描述
创建项目
在这里插入图片描述
个人项目(已创建的项目列表)
在这里插入图片描述
点击进入自己创建的新项目
在这里插入图片描述
创建团队项目
在这里插入图片描述
查看我自己的所有项目(个人项目、团队项目、演示项目)
在这里插入图片描述
点击“五角星”收藏指定项目
在这里插入图片描述
点击工作台,可以看到自己曾经收藏果的项目列表
在这里插入图片描述
查看数据
在这里插入图片描述
查看文档
在这里插入图片描述

查看彩蛋
在这里插入图片描述

至此,Centos7.x 安装、部署 easy-mock 服务(基于 Node、MongoDB、Redis 环境)操作完毕,希望能够对您有所帮助!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值