How to Host Node.js app on VM with CloudPanel
On this page
Hey, I’m Ajink. In this blog post, I’ll guide you on Host Node.js app on your virtual machine server using Cloudpanel. Let’s get started!
How to Install Cloudpanel on Your VM:
Follow this link for a step-by-step guide: Cloudpanel Getting Started.
Alternatively, you can watch my video tutorial:
Get Started to Host Node Js app :
Follow this Blog or Watch Video :
step 01 : login to your cloudpanel :
click on New site :
select Create Node.js site
Ensure that your domain is pointing to the server’s IP address. You can achieve this by adding an A record that points to your server’s IP address. If another application is already running on port 3000, you have the option to change it to any other available port.
Step 02: Location of Your Application Files
If your application is hosted on GitHub , you can retrieve it using Git. Alternatively, if the files are on your local machine, you can upload them to the site’s file manager folder.
Like here inside the htdocs inside the website folder .
we have completed step 2 , if your app is on github we will see it in step 3
Step 03 : open command prompt , bash or linux terminal
login to ssh using
ssh <username>@<server IP address>
enter your password and login (you can refer first video for it)
as you are logged in now write below command
sudo su - <username created when website is added>
cd htdocs
cd <website address inside htdocs the folder we have>
if you are getting your app from github , if you uploaded dont do this step
git clone <github repo link>
ls
cd <folder you get with above ls command >
step 4 : run the app
npm install
npm run dev
by any chance npm install is not working then add -force to it like
npm install -force
npm run dev
The node.js app will not start by itself in case the server reboots, so if you don’t want to go and manually start it we need to enable pm2 to auto-restart it.
npm install pm2@latest -g
after installing pm2
pm2 start npm --name <app name> -- <run command without np>
pm2 save
Add Cron To Start App On Reboot
echo $PATH
edit the crontab
crontab -e
PATH=<output of path>
@reboot pm2 resurrect &> /dev/null
completed done

references : https://www.bitdoze.com/install-cloudpanel-host-nodejs/
More in DevOps
See all →- How to Deploy a Flutter Web App to Vercel in 100 Seconds Flutter has become one of the most popular frameworks for building beautiful cross-platform apps, including web apps. If you’ve built a Flut...
- New to DevOps? Essential Tools and Their Official Documentation Venturing into the world of DevOps can be overwhelming given the myriad of tools available. Here’s a concise guide to some of the most widel...
- How to Exit Vim ? If you’ve ever found yourself stuck in Vim, unsure of how to exit, you’re not alone. Vim’s unique interface can be confusing at first, but f...
- How to Install Jenkins Install Jenkins : Jenkins is a widely adopted open-source continuous integration (CI) and continuous delivery/deployment (CD) tool that has...
- How to Create an Virtual Machine on Microsoft Azure , You can watch this video or continue on this post step 01 : visit portal.azure.com step 02 : click on virtual machines select on create az...
- Introduction to DevOps Hey , I am ajink in this blog will see Introduction to DevOps In the dynamic realm of cloud computing, these major players, AWS, Azure, and...