

Next, copy and paste the following pieces of code in the server.js files (replace 192.168.43.31 with your server IP). $ sudo vim /var/www/html/adminside/server.js Now, let’s create a testing application (we will assume it has a client and admin side which share the same database), the microservices will run on ports 3000, and 3001 respectively. On CentOS/RHEL and Fedora - Install Node.js v11.x -Ģ. On Debian/Ubuntu - Install Node.js v11.x. To install most recent version of Node.js and NPM, first you need to enable official NodeSource repository under your Linux distribution and then install Node.js and NPM packages as shown. Step 1: Install Nodejs and NPM in Linuxġ. We will create an app for demonstrating some of PM2’s fundamental features for you to get started with it. In this article, we will explain how to install and use PM2 to run Nodejs apps in Linux production server. PM2 is being used by companies such IBM, Microsoft, PayPal, and more.

In addition, it also has incredible support for major Node.js frameworks such as Express, Adonis Js, Sails, Hapi and more, without need for any code changes. It also allows you to easily manage app logs, and so much more. Notably, PM2 allows you to run your apps in cluster mode without making any changes in your code (this also depends on the number of CPU cores on your server).

It keeps your apps “ alive forever” with auto restarts and can be enabled to start at system boot, thus allowing for High Availability ( HA) configurations or architectures. It supports app monitoring, efficient management of micro-services/processes, running apps in cluster mode, graceful start and shutdown of apps. It works on Linux, MacOS as well as Windows. PM2 is a free open source, advanced, efficient and cross-platform production-level process manager for Node.js with a built-in load balancer.
