Git安装与配置,安装pm2
git config --global user.name "***"
git config --global user.email "***@qq.com"
ssh-keygen -t rsa -C "***@qq.com"
cat ~/.ssh/id_rsa.pub
自动化部署设置(ecosystem.config.js)
module.exports = {
deploy: {
production: {
user: '****',
host: '**.***.***.***',
ref: 'origin/master',
repo: 'git@gitee.com:***/***.git',
path: '/***/***/***',
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production',
ssh_options: "StrictHostKeyChecking=no",
"env": {
"NODE_ENV": "production"
}
}
}
};
- 初始化服务器远程文件夹(windows用Git Bash Here打开)
pm2 deploy ecosystem.config.js production setup
pm2 deploy ecosystem.config.js production
pm2 deploy ecosystem.config.js production update
scp ~/.ssh/id_rsa.pub ****@**.***.***.***:/root/.ssh/authorized_keys
firewall-cmd --list-ports
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --reload