Teaching Research and Publishings Speaking Engagements Professional Development About Me

Notice: Undefined variable: connect in /var/www/codeadam.ca/includes/header.php on line 20

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /var/www/codeadam.ca/includes/header.php on line 20

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /var/www/codeadam.ca/includes/header.php on line 22

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/www/codeadam.ca/includes/header.php on line 24

Server Setup Documents


Installing Node.js

Confirm that nano is Installed

which nano

If the nano package is not installed, install it:

sudo apt-get install nano

Installing Node.js

Install Node.js using the SSH command line.

Follow these commands:

sudo apt-get install npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Create Node.js Application

Using Codeanywhere create a folder called /var/www/apps. This is were we will place our Node.js applications. We will use a folder for each application. Ceate another folder called /var/www/apps/index:

Create a files called app.js in the index folder. Place this JavaScript in the new file:

#!/usr/bin/env nodejs
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080/');

Check File Permissions

Make sure that the permissions on the new Node.js file is set up properly:

sudo chmod -R 776 /var/www
sudo chown -R www-data:www-data /var/www