pm2在linux上运行
- 配置ecosystem.json文件
{
"apps": [{
"name": "[name]",
"script": "app.js",
"env": {
"COMMON_VARIABLE": "true"
},
"env_production": {
"NODE_ENV": "production"
}
}],
"deploy": {
"production": {
"user": "[用户名]",
"host": ["主机ip"],
"port": [端口],
"ref": "origin/master",
"repo": "git地址",
"path": "地址",
"ssh_options": "StrictHostKeyChecking=no",
"env": {
"NODE_ENV": "production"
}
}
}
}
21/tcp FTP文件传输协议
22/tcp SSH安全登录、文件传送(SCP)和端口重定向
3306 mysql
2 .上传git成功后
输入命令
pm2 deploy ecosystem.json production set up
3.进入Linux "path": "地址", 下
会自动生成目录
current -> /home/ubuntu/www/source/
shared/
source/
- 进入cd source目录
npm install (安装项目依赖插件,未安装node执行下条命令)
apt install nodejs-legacy (安装NODEjs)
- 安装pm2
npm install pm2 -g
![ZVZY_]7@4B8XJQG7N7X
JC.png](http://upload-images.jianshu.io/upload_images/4660972-53aebb1af341d7fb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
- 执行pm2
pm2 start www