0%

nuxt 发布部署

nuxt ssr 服务端渲染

打包

1
2
3
4
yarn build
npm run build

# 生成 .output

测试

1
2
3
node .output/server/index.mjs

# 正常运行

服务器运行 pm2 多进程

在.output添加ecosystem.config.js

1
2
3
4
5
6
7
8
9
10
11
12
13
module.exports = {
apps: [
{
name: "liaoruan",
exec_mode: "cluster",
instances: "max",
script: "./server/index.mjs",
env: {
NITRO_PORT: 3000
}
}
]
};

安装pm2\部署应用

1
2
3
4
5
6
nvm list
nvm use v18.20.2
npm install -g pm2
pm2 start ecosystem.config.js
pm2 list
pm2 stop 0

参考

  1. nuxt打包部署至服务器端
  2. pm2 命令