Deploy simple nestJs application on Server

1: install Node

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-20-04

curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh

nano nodesource_setup.sh

bash nodesource_setup.sh

apt install nodejs

node -v

npm -v

apt install build-essential

npm audit

2:install mongo
https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-20-04

curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -

curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse” | tee /etc/apt/sources.list.d/mongodb-org-4.4.list

apt update

apt install mongodb-org

systemctl start mongod.service
systemctl status mongod

systemctl enable mongod

mongo — eval ‘db.runCommand({ connectionStatus: 1 })’

3:Create a project folder and connect it to Git

Cd /usr/src
mkdir app

Cd app

Git init

git remote add origin https://gitlab.com/****

git pull origin main

git checkout -b dev

git branch — show-current

git pull origin dev

4: The project is now in the corresponding folder

Npm i

5: You can take the code under the correctness test

Npm run start:dev

6: Now we have to build the project

npm i -g @nestjs/cli

npm install pm2@latest –g

npm run build

pm2 start dist/main.js — name ***

7: And the end
The project can now be viewed at the link below

http://*.*.*.*:3000

Enjoy

--

--

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