All the steps required to deploy a simple node app on a server.
Note: we will be creating an app for hello.ifactory.co and assume DNS entries for *.ifactory.co resolve to the server.
$ mkdir /var/www/hello.ifactory.co/
$ touch /var/www/hello.ifactory.co/hello.js
$ nano /var/www/hello.ifactory.co/hello.js
const http = require('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World from NodeJS!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
After changes to Nginx configuraiton restart Nginx.