Skip to content

Instantly share code, notes, and snippets.

@davidchase
Last active August 29, 2015 14:06
Show Gist options
  • Save davidchase/37e72801f63928308ead to your computer and use it in GitHub Desktop.
Save davidchase/37e72801f63928308ead to your computer and use it in GitHub Desktop.
Setting Up Node on Amazon EC2

EC2 Amazon

Under EC2 select launch instances

Select the first instance linux box and proceed with the setup

Linux Box

Update the box it will probably tell you to do so anyways. sudo yum update

Install The GCC Compiler And Git

sudo yum install gcc-c++ make
sudo yum install openssl-devel
sudo yum install git

Git Node and Install

Specify latest version such as v0.10.31

git clone git://github.com/joyent/node.git
cd node
git checkout v0.10.31
./configure
make
sudo make install

Now you have node -v and npm -v

Update paths

sudo nano /etc/sudoers

find Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin

add :/usr/local/bin to the end of the secure_path

Port forwarding w/ iptables

Forward all 80 or http requests to 8080 thats where you listen to in the node app

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Accept connections on port 80

sudo iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT
sudo iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment