5

I have to ask you guys a question. I just started looking at NodeJS for a project with some friends of mine. Now we have reached the point in our planning that we have started to think about how a NodeJS solution is deployed in production. Do we need a web server for this (IIS or Apache)? My initial thought is "no" since this will force to declare ports twice, once in the web server and once in the NodeJS code. Or should NodeJS just be run as "node server.js"?

4

1 回答 1

7

您只需运行 NodeJS,node server.js但有一些更好的扩展可以处理这个问题。因此,您可以在 windows 中运行 node,但我强烈推荐 UNIX 平台通过 SSH 访问您的服务器(大多数 VPS 都有此功能)。如果你买不起这种类型的服务器,我会选择HerokuDotcloudNodejitsu(它们三个都是云托管)。

  • 永远在崩溃时重新启动您的节点服务器
  • 当文件被修改(或指定目录中的任何 JS 文件)时重新启动节点服务器的Nodemon

可能还有更多,所以如果我发现任何有用的东西,我会编辑这篇文章。

于 2012-09-14T05:11:24.087 回答