码迷,mamicode.com
首页 > 其他好文 > 详细

本地搭建easy-mock

时间:2018-10-10 17:08:53      阅读:864      评论:0      收藏:0      [点我收藏+]

标签:ubuntu   https   curl   退出   centos   http   安装docker   dock   docker   

 


easy-mock要用nodejs启动,需要先安装nodejs

ubuntu系统:
apt install node
centos系统:
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
yum install node

 

easy-mock依赖mongo和redis,需要确保服务器安装了mongo和redis,可以通过docker方式安装

安装docker

ubuntu系统:
apt install docker.io
centos系统:
yum install docker

 

安装mongo

docker pull mongo
docker run --name mongo -p 27017:27017 -d mongo

 

安装redis

docker pull redis
docker run --name redis -p 6379:6379 -d redis

 

easy-mock代码在github上,需要先安装git工具用于拉取代码

ubuntu系统:
apt install git
centos系统:
yum install git

 

从github上将easy-mock代码拉取下来

cd /home
git clone https://github.com/easy-mock/easy-mock.git

运行完之后代码就会下载到/home/easy-mock目录

下载npm相关的依赖包

cd /home/easy-mock
npm install

 

使用node直接运行easy-mock有个问题,easy-mock是在前台运行,如果会话退出了,进程也就退出了。为了保证进程能够一直运行,可以使用pm2后台启动进程。
安装pm2

npm install pm2 -g

 

启动easy-mock

cd /home/easy-mock
pm2 start app.js

 

本地搭建easy-mock

标签:ubuntu   https   curl   退出   centos   http   安装docker   dock   docker   

原文地址:https://www.cnblogs.com/lasdaybg/p/9767117.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!