Nuxtjs 是如何用 Nodejs 在 openlitespeed 上启动的?启动文件示例

How is Nuxtjs started on openlitespeed with Nodejs? Startup file example

正在尝试将我的项目上传到 openlitespeed。然而,遇到了困难。

基本节点设置是:

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World form node js app.js\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

看看如何包含模块如下:

var http = require('http');
var dt = require('./myfirstmodule');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write("The date and time are currently: " + dt.myDateTime());
  res.end();
}).listen(8080);

但是,我基本上可以 运行 我在本地主机上的 Nuxtjs 项目。

可能的预期结果是什么:

运行 VPS 上的 Nuxtjs 应用程序,它是 upcloud,带有一个启动文件,用于在 openlitespeed 上看到它的服务。

已在此处查看,但没有关于 openlitespeeed 部署的信息:https://nuxtjs.org/docs/2.x/deployment/nginx-proxy

嗨,经过一番研究后,这很容易:

https://nuxtjs.org/docs/2.x/deployment/deployment-pm2

将包含这些代码的名为 ecosystem.config.js 的文件复制到 Nuxt 的根文件夹中:

module.exports = {
    apps: [
      {
        name: 'NuxtAppName',
        exec_mode: 'cluster',
        instances: 'max', // Or a number of instances
        script: './node_modules/nuxt/bin/nuxt.js',
        args: 'start'
      }
    ]
  }

运行 在你的 linux:

killall node
cd /usr/local/lsws/serverclient/client
pm2 start

干得好