To install PM2, a process manager for Node.js applications, on AlmaLinux 9, follow the steps below:
Step 1 : Install PM2
First, make sure you have Node.js and npm installed. Then, install PM2 globally using npm:
Step 2 : Run PM2 Startup Script
To ensure PM2 starts automatically on system reboot, run the following command:
Step 3 : Build a Simple Node.js App
Create a simple Node.js application file, for example, app.js
:
Step 4 : Start the App with PM2
Start the application using PM2:
You can check the running processes with:
Step 5 : Manage Applications with PM2
PM2 allows you to manage applications easily:
- Restart the app:
- Reload the app (zero-downtime):
- Stop the app:
- Delete the app from PM2:
Congratulations! You have successfully installed PM2 on AlmaLinux 9