Deploy node.js express micro service to linux server and go live in 10?minutes

I have described the deployment in steps for a new server which does not have any software installed, but if you have those software installed, just skip those steps and move on to next.

Installations

  1. download nvm. NVM is a node version manager and in order to install Node and npm, first nvm is to be installed using following commands

/curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

. ~/.nvm/nvm.sh        

2. next install node and npm, the version should be the version as your application, if version is not given, the latest version will get installed

nvm install <<version>>        

3. for getting the code from any of your git repositories, install git package, skip this step if the code can be copied using any other way like ftp, winscp etc.

sudo dnf install git        

4. install pm2 server, pm2 is a package which ensures api running even system crashes, application crashes and such, it automatically restarts the app again

npm install -g pm2        

Deployment

5. copy the code to server directory wherever you want

git clone <<github or any other git repo url>>        

6. run the app using pm2

pm2 start app.js         

Ensure that the port eg. 3000 on which the node js application is listening is open on the server.

Now you can check the api end points using postman or browser. Replace localhost with ip of the server in all your end points.

要查看或添加评论,请登录

Samarth Srivastava的更多文章

  • Understanding AI Agents and Using Them to Generate Code

    Understanding AI Agents and Using Them to Generate Code

    AI agents are autonomous or semi-autonomous systems designed to interact with their environment, make decisions, and…

  • How to Create an NPM Package: A Step-by-Step Guide

    How to Create an NPM Package: A Step-by-Step Guide

    Creating and publishing your own NPM (Node Package Manager) package can be a great way to share useful code…

    2 条评论
  • Create Android App using responsive website

    Create Android App using responsive website

    Hey guys, so you want to make a android app but not sure about how to go about it. The easiest way to do it, is by…

    2 条评论
  • Deploy Angular app on Apache?server

    Deploy Angular app on Apache?server

    I have described the deployment in steps for a new server which does not have any software installed, but if you have…

    3 条评论

社区洞察

其他会员也浏览了