Install PM2 on Ubuntu, CentOS, Linux| TasteTheLinux

We will learn Install PM2 on Ubuntu and CentOS used to monitor as well as to manage the services of the NodeJS. Let’s view the bullet points for the PM2.

  • The Process Manager is also one of the NPM packages and many of the contributors worked to make the PM2 one of the best Managing tools in the Market.
  • TIll today’s date, PM2 was successfully released there 4.2.x version with weekly more than 4 Lakh downloads in the World level platform.
  • It always Monitors the node Process and keep the server up and running all the time.
  • It provides features like the Log Management, Also you can compress the logs by using the pm2-logrotate
  • The pm2 has come up with the feature of the Clustering, with the help of this feature we can implement the cluster on the server
  • So we can utilize the whole resources as well as we can increase the performance of the Application.
  • We can also say that there will be no downtime when we are using PM2.
  • We will suggest you use in the Production Environment, this is very reliable also our team is using in the Production Environment.
  • Now we will look into the basics of PM2 Monitoring. Before that, we will write a small nodeJS code and then run the code with the PM2.

Install PM2 on Ubuntu, CentOS

Step 1: You have to install NodeJS and npm on the Host.

You can click on the Link for the NodeJS installation on CentOS and in Ubuntu.

Step 2: We will write the code in the Node js

You can Find the Screenshot for the Program

First Program in Node js
var http = require('http');

http.createServer(function (req, res) {
  console.log('Welcome to Taste The Linux!');
  res.end('Welcome to Taste The Linux!')
}).listen(9000);

Create one file named as ” tastethelinux.js” in that you have to write the above code. Then you have to run the program in nodejs by using the below command:

node tastethelinux.js

Just go to browser and type http://localhost:9000 you will get the response like the attached screenshot

We have used 9000 port in the code [listen(9000)]

And the server Side we will get the logs like attached screenshot.

This Screenshot is from the backend server

But this will not continue up and running, if the application got crashed we have to again use the command “node tastethelinux.js” to start the server. This is a manual process. Do you think that the giant companies will afford any downtime, So let’s install the PM2

Step 3: Install PM2 in CentOS and Ubuntu

sudo npm install pm2 -g

output::
+ [email protected]
added 207 packages from 202 contributors in 17.254s

After the successful installation of npm package PM2. we will see how to start the pm2 and run the server forever and ever

Step 4: Start the PM2 Service

pm2 install, pm2 install ubuntu, pm2 install centos, pm2 install centos 7, pm2 install ubuntu 18.04, install pm2, install pm2 on centos 7, install pm2 on ubuntu, install pm2 ubuntu server, install pm2 on server, install pm2 linux, install pm2 on ec2, install pm2 on ubuntu 18.04, install pm2 on ubuntu 16.04
$ pm2 start tla.js 

So we have start our first process via PM2 that is “tla.js”

Now How to Install the PM2 Specific version

sudo npm install [email protected] -g

You can replace the version in the place of x.x.xx
If you have to learn more about the package then follow to PM2 npm.

To Learn the PM2 cheat sheets: click on the below URL
PM2 commands list, PM2 commands node, PM2 command line argument
NOTE: If we want to install pm2 on amazon linux then refer the same document.

pm2 install, pm2 install ubuntu, pm2 install centos, pm2 install centos 7, pm2 install ubuntu 18.04, install pm2, install pm2 on centos 7, install pm2 on ubuntu, install pm2 ubuntu server, install pm2 on server, install pm2 linux, install pm2 on ec2

 

3 Replies to “Install PM2 on Ubuntu, CentOS, Linux| TasteTheLinux

  1. like this article’s so first time who installing log monitor can understand with concepts clearly.

Give your valuable time