- Go to https://digitalocean.com
- Create an account
- Add your ssh key
- Buy some credits
- Create an Ubuntu instance with node and your keys, and get its IP
ssh root@YOURINSTANCEIP
apt-get install git nginx
git clone https://gist.github.com/b0146a2b8aa3c24d2dcb.git do-node && cd do-node
mv sites-available-default.conf /etc/nginx/sites-available/default
service nginx restart
mkdir public && mv index.html public/
npm i express
node main.js
- Go to http://YOURINSTANCEIP
You should see a page with a visit counter.
You should now quit the node process and:
npm i -g forever
forever start main.js
Note that if you delete and create an instance in the same region, ssh will fail till you'll remove the old entry from your ~/.ssh/known_hosts
. It's likely to be the last one in the file.
When you want to put this on a real domain, point your domain's A-record to your ip, replace localhost
with your domain name (i.e. example.com
) in /etc/nginx/sites-available/default
, and run service nginx restart
.