DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. How to Deploy node.js Apps to AWS from Mac OS X(I)

How to Deploy node.js Apps to AWS from Mac OS X(I)

Javier Manzano user avatar by
Javier Manzano
·
Sep. 12, 12 · Interview
Like (0)
Save
Tweet
Share
11.94K Views

Join the DZone community and get the full member experience.

Join For Free

After developing my first node.js app I decided to look where to host it. It had to be cheap and fast to deploy.

My first attempt was to deploy to heroku. It’s very very easy (if you’ve used git before… it could be the easiest thing you’ve ever done), but I think (and I tell that I only think because I didn’t finish deploying on it) is a little expensive. Every module you use have to be in its starter mode, or you have to pay for it.

So, after watching how many projects have successfully gone up with amazon web services, I decided to deploy on it. Maybe I’m wrong, but i think that for a small app, AWS could be cheaper than heroku (I’ll tell you after some months =) ).

Why am I writing this article? Maybe there’re some articles that refers to this… but I wanted to keep track of what I did in case I need it again.

First thing we have to do is to sign in AWS if you’ve not done before, and after that you must enter the AWS Management console and select EC2 (Virtuals servers in the cloud). You can click on the image to see it better.

After that you’ll be on the home page where you can do all the options available from EC2 like creating instances or key pairs

Now, we can launch our server instance to deploy our apps following the wizard. It’s very easy and on multiple AWS versions it’ll change, so I’m not uploading this images… but if you want to know I installed an Ubuntu 12.04 server.

After creating the server, you’ll have a key pair to connect via ssh (or however you want, but this is the way I’m doing here).

Once you have your keys, you can copy them into your .ssh folder: ~/.ssh, and give them the permissions to use it (i’m using a key pair called ubuntu.pem):

$ chmod 600 ubuntu.pem

To make the ssh connection you just have take the address to your server and connect typing your password. You can take the address from this page clicking on your instance (it’s the amazonaws’ string):

Now type the following, and you’ll be connected:

$ ssh -i .ssh/Ubuntu1204.pem root@address.amazonaws.com

After connecting to our AWS instance, we need to install git & node:

$ sudo apt-get update $ sudo apt-get install git-core curl build-essential $ sudo apt-get install openssl libssl-dev $ git clone https://github.com/joyent/node.git && cd node $ ./configure $ make $ sudo make install $ echo 'export NODE_PATH=/path_to/node' >> ~/.bashrc $ echo 'export PATH=$PATH:/path_to/node' >> ~/.bashrc $ source ~/.bashrc $ node -v

When all of this finish, we’ll get our node.js version and It’ll be installed (this will install last node version). To install another version, for example, 0.6.19, you need to checkout another branch before configuring:

$ git checkout v0.6.8

After this, you can run your own node js on amazon web services! but, for all node.js must be missing something: npm. This package manager makes all easier, and perhaps, you may have it on AWS too. So, to install it just do the following:

$ git clone http://github.com/isaacs/npm.git && cd npm/
$ make install

As always, you can install Express like this:

$ npm install -g express
Hope this helped!
In the next article I’ll show you how to use git to push your code to your AWS Server.
AWS Node.js app

Published at DZone with permission of Javier Manzano, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Continuous Development: Building the Thing Right, to Build the Right Thing
  • GitOps: Flux vs Argo CD
  • Using AI and Machine Learning To Create Software
  • ChatGPT — The Google Killer? The Job Taker? Or Just a Fancy Chatbot?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: