Node.js
Node.js is a JavaScript (ECMAScript) engine for building server side apps. It uses V8, Google’s open source high-performance JavaScript engine.
Node is Event/Callback driven - A callback function is registered for a specific event. When that event occurs the callback method is run.
A Public Server
In order to run node servers that are accessible to others via the internet, we’ll need somewhere to host it. At the moment, the easiest way to run a Node.js server is to use a company such as Digital Ocean which provides Virtual Private Servers. Digital Ocean has a few things going for them, first is the cost, second is the fact that you can get one running with Node.js already installed very quickly.
In order to get started, you’ll need to create an account with Digital Ocean.
After that, you can go ahead and create a “droplet” - this is Digital Ocean’s term for a VPS.
Choose an image: Ubuntu 16.04.1 x64
Move to tab ‘One Click Apps’: choose Node 4.4.5 on 14.04 - version # might change
Size: smallest is good
Datacenter region: whatever is closest to you
Choose a host name: I used ‘rtw’
Connecting to this Digital Ocean server via the Command Line
Digital Ocean will email you a password to use with the default “root” account. In order to do anything, you first have to login to the newly created server via the command line to change your password.
On a Mac, use Terminal, no windows use Command Prompt. Open the command line app and type the following command (the “ip_address” is in the email you got from Digital Ocean.)
ssh root@ip_address
You will be prompted to enter the password (which is also from the email) and then prompted to enter it again to change it. Go ahead and change it to something you will remember but sufficiently complex that it will be difficult for hackers.
Anytime you want to connect to your Digital Ocean server, use the ssh root@ip_address
terminal command and enter the password you just selected.
Uploading to the Server
In order to upload to your server, we need to use a tool that will allow us to connect via SSH to transfer the files. Fetch and Cyberduck are good tools for this, I prefer Cyberduck.
To connect via SFTP:
Choose SFTP (SSH File Transfer Protocol)
Server = the IP address emailed to you by Digital Ocean
Username = “root”
Password = whatever you just created in Terminal