如何为Web应用程序运行Node.JS服务器? [英] How to run Node.JS server for a web application?

查看:119
本文介绍了如何为Web应用程序运行Node.JS服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

信息:我是node.JS的新手!

Info: I am very new to node.JS!

我编写了一个示例服务器,该服务器可以侦听端口XXXX上的http请求.当我从命令行(Windows)运行此服务器时,它似乎运行良好.在浏览器中打开时,它会响应对localhost:XXXX的请求.

I have written a sample server that can listen to http requests on port XXXX. When I run this server from commandline (Windows) it seems to work well. It responds to the requests made to localhost:XXXX when opened in a browser.

问题:这是应该如何工作的吗?为了使节点服务器运行,是否应该始终打开CMD提示以使服务器侦听请求? 我不能对IISNode做某事"吗?

Question: Is this how this is supposed to work? For the node server to run, should there always be a CMD prompt open for the server to listen to requests? Can I not do "something" with IISNode?

我了解,如果我向JS文件发出请求,则在IISNode中将其标记为Node.JS文件,并且NODE应该对其进行处理;那么我将让Node为我处理请求. 但这假设IIS是我的Web服务器,并且特定请求可以由Node处理.

I understand that if I make a request to a JS files, which is noted in IISNode as a Node.JS file and that NODE should be handling it; then I will have Node handling the request for me. But then this assumes that IIS is the web server for me and that specific requests can be handled by Node.

我希望我在这里很有道理! :)

I hope I am making sense here! :)

推荐答案

我使用适当的方法解决了它.是的,它是IISNode..但是,似乎没有任何评论可以回答如何为同一IIS(还提供PHP,ASPX等)上托管的不同应用程序运行" app.js

I solved it using a proper method. Yes, IISNode it is.. But none of comments seemed to answer how to "run" app.js for different applications hosted on same IIS (which is also serving PHP, ASPX, etc)

第1步. 编辑节点应用程序的入口点(通常是app.js)以获取新的URL结构.

Step 1. Edit your node application’s entry-point (typically) app.js for the new URL structure.

快速应用程序假定它拥有整个URL空间,并从根本身开始URL,如下所示:

An express app assumes that it owns the entire URL space and starts the URLs from the root itself, as shown:





将您的app.js修改为如下所示(但将您应用的目录名称替换为"aaspass"!):

Edit you app.js to look like the following (but put YOUR app’s directory name instead of "aaspass"!!):





现在,将一个web.config文件放在您应用的根目录下,如下所示(您可以使用此模板:webconfig).





Now put a web.config file at the root of your app which looks like the following (You may use this template: webconfig).

再次编辑文件,并将名称"aaspass"更改为应用程序的目录名称.


Again edit the file and change the name "aaspass" to your app’s directory name.


就是这样!您可以根据需要对任意数量的应用执行此操作,并将其托管在SAME服务器上.

Thats it! You may do this for as many apps as required and host them on SAME server.

这篇关于如何为Web应用程序运行Node.JS服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆