如何为apache on Next.js配置ecosystem.config.js文件

问题描述 投票:0回答:2
AM尝试使用PM2在Apache上部署NextJS应用程序。 我已经安装了最新版本的节点PM2。和Apache被配置为反向代理。 但是,当试图启动守护程序过程时,它没有这样做。我从github和ran'npm run build克隆了一个项目,该项目创建了.next文件,并且在该文件中,我为PM2创建了EcoSystem.config.js文件,它看起来像这样:

module.exports = { apps : [{ name: "nextjs-app", script: "npm", args: "run build", env: { NODE_ENV: "production" } }] };
但是当我跑步时,终端给了我这样的呼吸:

pm2 start npm -- start 

但是,当我尝试查看过程列表时,没有,当用户尝试输入网站时,网站日志显示端口3000
没有服务
pm2 start npm -- start [PM2] Spawning PM2 daemon with pm2_home=/home/georgianar/.pm2 [PM2] PM2 Successfully daemonized [PM2] Starting /usr/local/bin/npm in fork_mode (1 instance) [PM2] Done.


(111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:3000 (localhost:3000) failed

我不知道为什么,任何人知道为什么这样做?
	

如果您只想使用PM2运行已经部署并构建的下一个应用程序,则不需要生态系统文件。

即将从项目根文件夹运行:
reactjs apache next.js server pm2
2个回答
0
投票
AH01114: HTTP: failed to make connection to backend: localhost

您的文件应该像这样:
pm2 start npm --name "app_name" -- start

0
投票
然后运行:

ecosystem.config.js

.

这里的关键要点是,

module.exports = {
  apps: [
    {
      name: "your-app-name",
      // path to `next` from `node_modules` (the lack of `./` at the start of the path is on purpose)
      script: "node_modules/next/dist/bin/next",
      args: "start",
      env_production: {
        NODE_ENV: "production",
      },
      // ...other config
    },
  ],
};


值应指向

pm2 startOrReload ecosystem.config.js --env production

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.