# 一、配置部署脚本文件
部署参考 http://blog.poetries.top/2018/11/18/react-ssr-next-deploy/
在项目根目录添加
pm2的部署脚本文件ecosystem.json
{
"apps": [
"name": "movie", //对应Nginx上的配置
"script": "app.js", //入口文件
"env": {
"COMON_VARIABLE": "true"
},
"env_production": {
"NODE_ENV": "production"
}
],
"deploy": {
"production": {
"user": "poetries", //Nginx服务器上的username
"host": ["120.120.14.21"], // 服务器地址
"port": "3922",
"ref": "origin/master", //从指定的分支拉取代码
"repo": "git@github.com:poetries/poetries.github.io.git",
"path": "/www/movie/production",//发布到服务器指定的目录下
"ssh_options": "StrictHostKeyChecking=no",
//构建在发布
"post-deploy": "npm install --registry=https://registry.npm.taobao.org && grunt build && pm2 startOrRestart ecosystem.json --env production",
"env": {
"NODE_ENV": "production"
}
}
}
}
@前端进阶之旅: 代码已经复制到剪贴板
# 二、配置Nginx的server
在
nginx安装目录下的vhost中新建一个xx-3000.conf的配置文件
upstream movie { // website项目的目录名称
server 127.0.0.1:3000; // 服务器上的本地启动入口
}
// 配置server
server {
listen 80;
server_name movie.poetries.top; //指向的域名
location / {
proxy_set_header X-Real-IP