Deploy NodeJS Project in Ubuntu Server

Let's See The Standard Way To Deploy NodeJS 

Project with Nginx 



Firstly I assume you already connected to your Ubuntu server.

Now first command which you need to run is

~ sudo apt-get update
(This command will update all default packages of ubuntu server with latest versions)

Now let's install Nginx server

~ sudo apt install nginx

Now you have to install Node JS and NPM (Please read this article for it)

Now you can check with
~ nginx -v
~ node -v
~ npm -v 
NodeJS - Education Funda


In each above commands version should be written if not it means it not installed properly in your server.

now go to cd /var/www directory
-> From here create directory sudo mkdir domain.xyz.
-> cd domain.xyz.

From here take clone from your GIT branch (Reference Link)

Now go to ~ cd yourCloneDirectory.

-> From this directory just run your project ~ node app.js/server.js (your root file of node js project)

Now just call your IP or Domain in your browser your project should run now.

Run Node JS Project in Background:


For achieving it you can use PM2 package, which is project manager package to run services in background.

You can install it via:

~ sudo npm install pm2 -g

Now just run below command to run your project in background:

~ pm2 start app.js/server.js/index.js (your root file)


That's it !!

Guys you have done it now ✌


I hope this blog will be helpful for you if YES then please don't forgot to comment and share.

Happy Coding !!

Comments