Set up Web Server

Sys Admin's often manage web servers. Node.js allows us to program server actions with JavaScript. In this challenge, we'll install it and create a simple server.

Install Node.js

In Terminal, type:

sudo apt-get install node

node install

Type Y when prompted. When it's finished you can double check that you've got it by checking the version:

node -v

node version

Write Simple Server

We'll use a simple server from Felix's Node.js Beginner's Guide. Create a new text document and copy the code below and save the file as hello.js in your Documents folder.

var http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end('Hello Http');
});
server.listen(80);
console.log('Listening on 80')

script

Now, in Terminal navigate to your Documents folder:

cd 
cd Documents

Run the file:

sudo node hello.js

Now open the Firefox browser and visit localhost:80. There it is!

localhost

Visit Remotely

Because we left port 80 open in our firewall, we can access this server remotely from within the network. For the remote address, we'll need to get our IP address:

/sbin/ifconfig | less

Now you can get to the same server by visiting http://________

To complete this challenge, take a screenshot of localhost:80 in your browser.