nginxpublish

nuxt服务端渲染部署

  1. npm run build
  2. 打包完成后,将下面文件夹
.nuxt/nuxt
static
nuxt.config.js   //有反向代理需要这个
package.json

提交到服务器

  1. npm install
  2. npm start(不推荐直接这么运行)
  3. pm2 start npm -- run start (推荐使用这个进程守护执行)
  4. 访问 ip/域名:3000 (3000 是 nuxt.config.js 的端口号设置,默认是 3000)
  5. nginx 配置虚拟主机反向代理到步骤 6 的地址

具体 (opens new window) 具体 (opens new window)

module.exports = {
  apps: {
    name: 'ssr-server',
    exec_mode: 'cluster',
    autorestart: true,
    max_memory_restart: '512M',
    instances: 2, // Or a number of instances
    script: './node_modules/nuxt/bin/nuxt.js',
    args: 'start',
    ignore_watch: ['node_modules', 'logs', 'public'],
    error: './logs/nuxtjs/app-err.log', // 错误日志路径
    output: './logs/nuxtjs/app-out.log', // 正常日志路径
    log_date_format: 'YYYY-MM-DD HH:mm:ss', // 指定日志文件的时间格式
    env: {
      MODE: 'dev' // 环境参数
    }
  }
}
上次更新: