This tutorial will walk you through installation process to provision node js application into EC2 easily, this tutorial assumed readers that they have knowledge in the following domains:
- Amazon web services
Login through aws console and launch a new EC2 instance (micro instances for experimental purposes)
Through Connect inside EC2 check how to connect to your new spinned machine (note that users differ according to operating system, ubuntu in case of Ubuntu OS and root in case of redhat-based systems)
I am assuming that you are using Ubuntu here, run the following:
$ sudo su # apt-get update # apt-get install curl -y # curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - NOTE: -s stands for silent -L location and follow redirects # apt-get install -y nodejs # apt-get install -y build-essential # npm install --g nodemon
Usually this process takes time from us to run every time we are going to spin up a new machine into the cloud, that why “user data” is much helpful in case we need to run the whole script whenever the machine is booting moreover we can pull code from git repos and deploy our application automatically which helps alot in case we need to scale our app quickly.
A more matured technique is to build the base box and save into an image then make autoscaling groups that can spin an image then in the “user data” we can only automate the fetch of our code from git repos.
For more info related to installation of nodejs in ubuntu, check out this article