A consise guide to Nodejs and Express running on Amazon AWS

This is a summary of the tutorials I used to set up my first Amazon AWS server with NodeJS and Express. Links to the full tutorials are listed at the end of this post, if you get stuck please consult them.

Create an Amazon AWS account

  1. Get out your credit card and phone
  2. Go to: http://aws.amazon.com/
  3. Create your account

Create an EC2 instance

  1. Go to:  http://console.aws.amazon.com/ and sign in.
  2. Select region (top right).
  3. Click EC2 (top left).
  4. Click the Launch Instance button.
  5. Select the Amazon Linux AMI AWS (server image).
  6. Click Review and Launch.
  7. You will now get a warning that your server is “open to the world”.
  8. Click the Edit security groups link.
  9. On the SSH line select “My IP”. You will now only be able to SSH to the server from your current IP.
  10. Click Add Rule and add a HTTP rule.
  11. Click Add Rule and add a HTTPS rule.
  12. Click Review and Launch.
  13. Click Launch.
  14. Create a new Key Pair and download the .pem file. Keep this file in a secure place. If you lose it you will never be able to access your server again.
  15. Congratulations you now have server running on Amazon AWS!
  16. Click View Instances
  17. In the list of instances take note of the “Public DNS” and the “Public IP” of your server instance.

Connect to your Instance via ssh

To connect you need your key.pem file, and your Public IP. The default user for the Amazon Linux AMI is ec2-user:

$ ssh -i key.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com

Update, install the compiler and git

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

Install nodejs

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

Add node to sudo’s path

$ sudo su
$ nano /etc/sudoers
# Add :/usr/local/bin to the end of this line:
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
$ ctrl + x and save
$ exit

Install NPM

$ cd
$ git clone https://github.com/isaacs/npm.git
$ cd npm
$ sudo make install

Install express and start the server

$ cd
$ sudo npm install -g express-generator@4
$ sudo express foo
$ cd foo
$ sudo PORT=80 npm start

Go to your browser and enter your Public IP

 Celebrate your awesomeness!



A complete guide:


Connecting to your AWSEC2 server with ssh:


AWS settings and GIT:


Leave a Reply

Your email address will not be published. Required fields are marked *