Reputation: 51
How can I host node.js application on windows server?
Upvotes: 5
Views: 15475
Reputation: 27997
I suggest you use iisnode to achieve your requirement.
You should firslty install the IIS URL Rewrite extension, node.js, iisnode.
After you installed above things, you could find you IIS Modules contains the IISnode feature, then you could run your node.js application on IIS as other web application.
More details about how to host node.js application, you could refer to below article.
Upvotes: 3
Reputation: 1905
1) install nodejs (Download from here)
2) write your server program (it should contain a proper node.js listener code)
3) run your code; open a Powershell or CMD and type the following command:
node my_server.js
you can also refer to these links:
Install Node.js and NPM on Windows
PM2 | process manager for Node.js
P.S:
Here is a very very simple node.js server code (from node.js docs here):
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!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Hope it helps!
Upvotes: 2