Learn how to install PM2 Plesk. Our Plesk Support team is here to help you with your questions and concerns.
How to Install PM2 Plesk
When it comes to managing and deploying Node.js applications, having a reliable process manager is crucial. PM2 is an advanced and efficient open-source process manager for Node.js. It offers a complete solution for production-level application management.
Furthermore, its built-in load balancer, support for app monitoring, and seamless integration with major Node.js frameworks, have made PM2 popular.
Today, we going to take a look at how to deploy a Node.js application on Plesk.
How to Connect the Node.js Server
In order to deploy a Node.js application on Plesk we have to connect the Node.js server.
Here is how it is done:
- First, we must install Git and the Node.js extension in Plesk.
- Then, we have to make sure the application code is compatible with SSH authentication.
- Next, we have to run the NPM install command to install all the project modules.
- Now, create a subdomain for the server, and set the root folder as httpdocs/api
How to manage Environment Variables
- First, create a .env file with the required environment variables as seen below:
module.exports = {
apps : [{
name: “app”,
script: “./start.js”,
env: {
NODE_ENV: “prod”,
PORT:8080,
{YOUR_OTHER_VARIAVLES}
}
}]
} - Next, set the environment variables via the “Custom environment variables” field since the extension in Plesk may not support running custom scripts.
How to use PM2 for Process Management
- First, we have to access the server files through the terminal. It is usually located in /var/www/vhosts/domain_name/httpdocs/api/.
- Next, we must install the PM2 library globally with this command:
npm i pm2 -g
- Then, run this command to start the server, as it might not work with pm2 start npm — start.
pm2 start start.js
- Now, it is time to create an ecosystem.config.js file in the root folder of the Node.js server. Then, we have to configure it to include the needed environment variables and settings.
- Finally, run this command to launch the server with PM2.
pm2 start
How to configure Nginx
- Now, it is time to head to “Apache & Nginx settings” in Plesk.
- Then, locate the “Additional Nginx directives” field and add the new configuration.
- Finally, save the changes.
At the end of the day, PM2 helps simplify deploying Node.js applications on Plesk.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In summary, our Support Techs demonstrated how to deploy a Node.js application on Plesk with PM2.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments