Table of Contents

Install Node.js on Ubuntu 16.04

Introduction

Install Node.js and dependencies

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
  • Note that we are using an older version of socket.io (0.9.x) instead of the latest 1.x.
  • Also note that there might be some warings during the install of these packages. Thats normal.
sudo npm -g install tail
sudo npm -g install socket.io@0.9.x
sudo npm -g install connect
sudo npm -g install mysql
sudo npm -g install forever

Add start-up script

#The systemd startup file
sudo cp /usr/share/nginx/html/cake2/rd_cake/Setup/Node.js/nodejs-socket-io.service  /lib/systemd/system/
 
# add a sym link to node
sudo ln -s /usr/bin/nodejs /usr/bin/node
 
#Enable it
sudo systemctl enable nodejs-socket-io.service
 
#Start it
sudo systemctl start nodejs-socket-io.service

Test the Node.js server

sudo cat /var/log/nodejs-socket-io.log
#Result in....
info: socket.io started
Up and running on port 8000

Things to remember about Websocket

Next steps