How to Install PM2 in Ubuntu 23.04

To install PM2 on Ubuntu 23.04, follow the steps below.

Step 1 : Install PM2

Begin by installing PM2 using npm (Node Package Manager). Open a terminal and run the following command:

This command installs PM2 globally on your system.

Step 2 : Run PM2 at Startup

To ensure PM2 starts automatically at boot, run the following command:

Step 3 : Build a Simple Node.js App

Create a basic Node.js application. For example, create a file named app.js with the following content:

Step 4 : Start the App with PM2

Start your Node.js app using PM2 with the following command:

Replace app.js with your application file and my-app with the desired name.

Step 5 : Manage the App with PM2

You can manage your app using PM2 commands. Here are some examples:

- Restart the app:

- Reload the app:

- Stop the app:

- Delete the app from PM2:

Congratulations! You have successfully installed PM2 on Ubuntu 23.04, created and managed a simple Node.js app using PM2.