For this week, we learned how to use web socket and server to host our website.
First, go to Digital Ocean to register an account. On Digital Ocean, we will be able to get an IP address.
Secondly, open the terminal. In the command line, follow these steps:
ssh root@the IP address from digital ocean
installing node and nmp:
apt-get update apt-get install nodejs apt-get install nodejs-legacy apt-get install npm
server.js/index.html –>put them somewhere on your computer
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. I have found that Fetch and Cyberduck are good tools.To connect, choose “SFTP”, under “Hostname” or “Server” use the IP address emailed to you by Digital Ocean. The “username” is “root” and the “password” is what you just created in Terminal.
To Run it
ssh root@YOUR_IP cd directory_you_just_created npm install socket.io node server.js website: http://YOUR_IP:8080/index.html I just modified the sample code a bit and made it also reply to the sender's side a bit: