Javascript Node.js 可以在 Tomcat 服务器中运行吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12618306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 10:51:01  来源:igfitidea点击:

Can Node.js be run within Tomcat server?

javascriptnode.js

提问by Nav

From what I have read so far in this blog http://nowjs.com/I need to install nodejs in the server machine for it to work. But, I am using a shared server and don't really have any authority to put something into the server machine.

从我目前在这个博客http://nowjs.com/ 中读到的内容来看,我需要在服务器机器上安装 nodejs 才能工作。但是,我使用的是共享服务器,实际上并没有任何权限将某些内容放入服务器机器中。

Putting it into the container(tomcat) is however another thing which I mostly do. Generally speaking, when we say server we mean tomcat or websphere or jboss.

然而,将它放入容器(tomcat)是我最常做的另一件事。一般来说,当我们说服务器时,我们指的是 tomcat 或 websphere 或 jboss。

But with nodejs if I am not wrong server means the real machine on which tomcat etc. runs.

但是如果我没有弄错的话,使用 nodejs 服务器意味着运行 tomcat 等的真实机器。

So is there any way I can run the nodejs server inside tomcat server or am I thinking about it the wrong way ?

那么有什么方法可以在 tomcat 服务器中运行 nodejs 服务器还是我想错了?

采纳答案by thomas-peter

Yes, you are thinking of it it the wrong way. The key feature of Nodejs is that it contains, amongst other things, a rather natty embedded HTTP server. Think Jetty. However it mightbe possible now or in the future to run JavaScript in tomcat.

是的,你想错了。Nodejs 的关键特性是它包含一个相当整洁的嵌入式 HTTP 服务器。想想码头。然而,它可能现在或将来给Tomcat运行JavaScript成为可能。

I recommend going to http://nodejs.org/and watching the video, it will surely clear the matter up for you.

我建议去http://nodejs.org/并观看视频,它肯定会为您解决问题。

Meanwhile I would recommend getting hosting which includes SSH access, and preferably root access. Root access will make installing node a whole load easier and allow you to run it on a commonly used port (avoid running node as root, use port mapping) . But you don't need a seperate web server to get started, you can install Node.js on windows, mac and linux.

同时,我建议获得包含 SSH 访问权限的托管服务,最好是 root 访问权限。根访问将使安装节点更容易,并允许您在常用端口上运行它(避免以根身份运行节点,使用端口映射)。但是你不需要单独的 web 服务器来开始,你可以在 windows、mac 和 linux 上安装 Node.js。