How-to Quick-Start with Node.js as Web Server on Elementary OS GNU/Linux

May 19th, 2015 by thelinuxevangelist

Node.js Web Server Quick-Start for Elementary OS Linux

The Linux Tutorial Shows You Step-by-Step How-to Install and Getting-Started with Node.js as Html Web Server on Elementary OS 0.2-Luna/0.3-Freya/0.4-Loki i386/amd64 Linux+GNU Desktop.

Node.js is an Amazing New Javascript Stuff that is at the Same Time either a Web Server and a Web Development Framework.

Node.js is Well Known for his Performances and Scaling Attitudes derived from a Single Thread Non-Blocking Architecture “First come, first served”.

Node.js Quick-Start on Elementary OS - Featured
  1. Open a Shell Terminal Emulator Window
    Ctrl+Alt+t on Desktop
    (Press “Enter” to Execute Commands)

    Linux Elementary OS Node.js WebServer Quick-Start - Featured
  2. How-to Install Latest Node.js on Elementary OS Linux:

    Node.js Installation for Elementary OS
  3. Installing Needed Node.js Modules

    sudo npm install content serve-static
  4. Making Node.js WebServer Directories
    Example:

    mkdir -p ~/Documents/node.js/webserver/static
  5. Making Node.js WebServer Script

    cd ~/Documents/node.js/webserver
    nano webserver.js

    Append something like:

    var connect = require('connect');
    var serveStatic = require('serve-static');
    
    var app = connect();
    app.use(serveStatic("./static"));
    app.listen(5080);
    

    Ctrl+x to Save & Exit from nano Editor ;)

  6. Running the Local WebServer

    node webserver.js
  7. Creating a Hello World Node.js Html

    nano ./static/hello.html

    Insert some Html content like:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Hello-World from Node.js</title>
    </head>
    <body>
    Hello World from a Node.js WebServer!
    </body>
    </html>
    
  8. Open Html Page on Browser
    Point to:

    http://localhost:5080/hello.html

    You should be Happily Greeted with an: “Hello World from a Node.js WebServer!”

(Visited 2 times, 1 visits today)
Share on Tumblr

Tags: , , , , , , , , , , , , , , , , , , , , , , ,


Comments are disabled