Deploy NodeJS APP in AWS LightSail Using NodeJs Blueprint

“Developer Friendly Deployment Doc’s”

This article is focused on the deployment of NodeJs Application in AWS LightSail using NodeJs instance in simple developer-friendly configurations.

Prerequisites to Proceed Further

  1. Basic in NodeJs
  2. Basic in Linux Commands
  3. Basic in LightSail Console

Deploy the NodeJs APP to Light Sail

Login to the AWS console and search or Navigate to the Light Sail console below shown image and click on the create instance for creating a server.

LightSail console

Next you have to choose the Image you want for your server since most of the nodejs applications runs based on the Ubuntu server i choose Nodejs Blue print (For advanced users can choose the OS only option and manually configure all needs) then scroll down for next,

Select the blueprint you have need

Next we have to create or download the ssh key pair for our instance login to create a new one and download the key pari we have to click on this below shown image

ssh key pair creation and download

And you will get like the below shown image from that 1 can create new key 2 for downloading the default key in that i choose 1

create new key

While clicking the create new will ask for creation of instance on the selected zone and click on create button

After that you will as for a new name for the key as like the below image shows, 1 ask to input the name and 2 act as generate key button do all the task

Next you have successfully created the ssh key now you want to download and safe the SSH Key

Download the Key

Below image shows how the key look like when we download its a .pem extensional file then scroll down

downloaded pem file

Next you have to choose the type of instance plan you want here i choose the default plan and scroll down

Next we have to name our instance you can change the name as per your project in 1 i named it as “ nodejsapp “ and the 2 show the number of instance you want i go with the default and scroll down

Next you have to create the instance by clicking the Create Instance button and wait for the creation

create instance

Wait until the instance created and you will get a console like the below image shows

LightSail Instance

After creation of Instance will show like the above image and you have to notify and remember some points like

1 Your Server IP

2 Region and Zone

3 Server Name and Configurations

•••••••••••••••4 Server Status

Instance Configurations

After that copy the IP to your web browser. To check whether the instance working. Prefect or not if its working fine you will get the screen like below image

run the IP in your Browser

After that go to your ssh terminal by clicking the terminal icon on the instance or click the connect from the menu drop down

SSH Terminal

From that you have to clone your project in to the root directory of the server in the case of LightSail NodeJs the root directory is,

cd /opt/bitnami/apache2/htdocs

current root path

you can verify the root path is correct by changing the html with some other code and run it on your ip

So navigate to the root directory using the above command and clone your project inside the html folder by git clone command

git clone <paste project git url>
clone the project

After successfully cloned the project navigate to the project directory. Using “cd” and to list the folders inside the project folder type “ls”.

After that install node package by running the below command,

npm install
npm install to your project

create a conf folder under bitnami using the below command

sudo mkdir /opt/bitnami/conf

Navigate to the Newly created directory using the below commands

cd /opt/bitnami/conf

and create a new file httpd-prefix.conf using the below command

sudo nano /opt/bitnami/conf/httpd-prefix.conf

and insert the below content , and save the file

Ctrl+O for save and Ctrl+z for exit

Include "/opt/bitnami/conf/httpd-app.conf"

Then create another file of name httpd-app.conf using the below commands,

sudo nano /opt/bitnami/conf/httpd-app.conf

Insert the below code to the newly created file as below image shows and save, exit

Ctrl+O for save and Ctrl+z for exit

Add ProxyPass /<your port>/

ProxyPassReverse /<your port>/

here my project running or port 3001 so i set the ProxyPass to 3001 you can change the port as your project work

Later the conf folder will look like this if you “ls” list the folder

Next you have to Navigate to the bitnami configuration folder using the below command and list the files inside the folder,

cd /opt/bitnami/apache2/conf/bitnamils

Next you have to edit the bitnami.conf and include our httpd-prefix.conf in that, for that you have to run the below command refer the below images also,

sudo nano bitnami.conf

then paste the below include code in the last section

Include "/opt/bitnami/conf/httpd-prefix.conf"

Ctrl+O for save and Ctrl+z for exit

after that we need to restart apache using the below commands,

sudo /opt/bitnami/ restart apache

Configure MongoDB In Light Sail NodeJS Server

Next step we have to install and setup mongoDB inside the Light Sail NodeJs server for that you have to run the below Steps run in Terminal, here we are using bitnami mongo installer since light sail runs on bitnami,

run the below commands

sudo apt-get install software-properties-commonsudo apt-get update

Download the mongo-bitnami installer using the below command,


After successfully download list the downloaded file using “ ls” command

List the folders

Next you have to give permission to the downloaded installer for that run the below command,

chmod 755

for my case the APPNAME-VERSION is mongodb-4.0.3–1-linux-x64-installer (you can simply fetch the name by clicking TAB).

Next we have to run the installer for that run ./ infront of the file name and click enter

Run Installer

After clicking enter it will run the mongodb installation and you will ask for a MongoDB Server root password enter a secret password you have known and click Enter will as to retype the password,

Click enter after the reenter password and you will ask for a verification to install continue click Y and Press Enter

Wait until the installation complete…

After the installation they will ask for Launching the Bitnami MongoDB Stack Type Y and Press Enter

It will complete all the installation part now you have to Test the MongoDB working perfectly by running the command,


type exit to exit from mongoDB

Next Configure the Virtual Host (vHost)

For configuring the virtual host you need to Navigate to vhosts using the below command

cd /opt/bitnami/apache/conf/vhosts
setup vhosts

list the files inside the vhost using “ls”

Files inside the vhost

you can see Two disabled vhost configuration take a copy of both, you can do copy with below commands,

sudo cp -r sample-vhost.conf.disabled sample-vhost.confcp -r sample-https-vhost.conf.disabled sample-https-vhost.conf

After copying the files we can list the files like the below image

Next we have to insert our project configuration to the copied configuration for that,

Conf 1:

sudo nano sample-vhost.conf
edit vhost configuration

click enter to enter the nano editor and change the Document Root, Directory Path, and Port number as below images,

Current Configuration

change the document root and directory as per your project path for my case,


Ctrl+O for save and Ctrl+z for exit

Changed configuration

Conf 2:

sudo nano sample-https-vhost.conf
htts-vhost configuration

click enter to enter the nano editor and change the Document Root, Directory Path, and Port number as below images,

current configuration

change the document root and directory as per your project path for my case,


Ctrl+O for save and Ctrl+z for exit

Changed Configuration

Run Your NodeJs Project

Next step is to run you project for that navigate to your project root folder

cd /opt/bitnami/apache2/htdocs/nodejs-admin

Now run the npm start for running your project

Run the IP on your browser to check the working of your application…!!!!!!

Start your npm forever using the below command

cd /opt/bitnami/apache2/htdocs/nodejs-admin/binforever start www




DevOps Engineer / Solution Architect- Calicut

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Internationalization of React App using Google Sheet and react-i18n

JavaScript functions

Loading JavaScript, CSS, or Image Files with a Promise API

React Native FAQ for 2021: All You Need to Know

Commonly-Used JavaScript Array Methods


Micro Frontend in Angular


Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akshay Krison

Akshay Krison

DevOps Engineer / Solution Architect- Calicut

More from Medium

CI/CD using GitHub Actions, Build/Push Docker Image to Docker Hub

Multi-containarized react appliation with nginx as a reverse proxy using docker-compose


How to Deploy Next.js App to AWS EC2 in Production and Set up CI/CD with Github Actions