Deploying Node, Mongo to AWS EC2

This guide assumes you have already set up the environment and downloaded the .pem file. Make sure you put the .pem key somewhere safe.

Connect to environment

Click on your instance and hitting “Connect” — you’ll see a URL like this. Copy and paste it into terminal:

ssh -i “<LOCATION OF PEM KEY>” ubuntu@<amazon aws url>

Install Mongo on your VM

The documentation is on point:

Install Node on your VM

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Installing Node installs NPM.

Install Express on your VM

sudo npm install -g express

Change IP tables on your VM

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080  
sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -o lo -j REDIRECT --to-ports 8080

See this guide for reference.

Edit your security groups on AWS

Clone your git repo

In /home/ubuntu:

npm install

Start your server

node server.js

Visit your new page

Get your public DNS from your Amazon console page.

<amazon public DNS here>:8080


One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.