DEV Community

Cover image for Setup VPS server with Cpanel for Nodejs Application (DNS, Mail)
Nurul Islam Rimon
Nurul Islam Rimon

Posted on • Edited on

Setup VPS server with Cpanel for Nodejs Application (DNS, Mail)

connect to the terminal using your creadentials and install dependencies

  • example
ssh root@192.168.5.10
Enter fullscreen mode Exit fullscreen mode
  • update & install Hestiacp
sudo apt update && sudo apt upgrade
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
wget https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.sh
sudo groupdel admin
bash hst-install.sh
Enter fullscreen mode Exit fullscreen mode

** If hestiacp installed successfully it will provide a credential to login in the Cpanel

  • example:

Admin URL: https://vmi2311142.contaboserver.net:8083

Backup URL: https://82.192.71.175:8083

Username: admin

Password: 5vFZn4jEx8Qowh7w

visit admin or backup url and login with username & password

  • create new user and create web for your application
    • example: bdcommerce.app

Image description

  • add ssl and alias from edit domain
    • example (alias): www.bdcommerce.app

open new terminal & connect: sftp remote-user@remote-server-ip (then your password)

  • if connected you can upload any file using: put
    • example:
sftp root@82.197.71.175  (password)
put your-file-path
Enter fullscreen mode Exit fullscreen mode
  • close connection
exit
Enter fullscreen mode Exit fullscreen mode

connect to the terminal again: ssh remote-user@remote-server-ip (then your password) and install node, npm and pm2

nvm install --lts
npm i pm2 -g
Enter fullscreen mode Exit fullscreen mode
  • now unzip the files
    • example:
unzip app.zip
Enter fullscreen mode Exit fullscreen mode
  • move folders to the domain path
    • example:
mv file-path/* new-path
Enter fullscreen mode Exit fullscreen mode
  • Now go to the file path
    • example:
cd /home/file-path
Enter fullscreen mode Exit fullscreen mode
  • install all dependencies
    • example:
npm i
Enter fullscreen mode Exit fullscreen mode
  • run the application using pm2
    • example:
pm2 start npm --name api -- start
Enter fullscreen mode Exit fullscreen mode
  • check the server's output
    • example:
curl localhost:5000
Enter fullscreen mode Exit fullscreen mode
  • config domain first go to the nginx config file by Hestia for your app
    • example (replace with your path-name):
nano /home/bdcommerce/conf/web/bdcommerce.app/nginx.conf
Enter fullscreen mode Exit fullscreen mode
  • replace proxy_pass with your running port
    • example:
proxy_pass http://localhost:5000;
Enter fullscreen mode Exit fullscreen mode

** save the file 'ctrl+o' then 'enter' then 'ctrl+x'

  • config ssl domain
    • example:
nano /home/bdcommerce/conf/web/bdcommerce.app/nginx.ssl.conf
Enter fullscreen mode Exit fullscreen mode
  • replace proxy_pass with your running port
    • example:
proxy_pass http://localhost:5000;
Enter fullscreen mode Exit fullscreen mode

** save the file 'ctrl+o' then 'enter' then 'ctrl+x'

  • Restart the nginx server
sudo systemctl restart nginx

Enter fullscreen mode Exit fullscreen mode
  • check domain if proxy is working or not
    • example: curl bdcommerce.app

Note: If everything is working then make sure HestiaCP will not change the Nginx config:

chattr +i /home/bdcommerce/conf/web/bdcommerce.app/nginx.conf
chattr +i /home/bdcommerce/conf/web/bdcommerce.app/nginx.ssl.conf
Enter fullscreen mode Exit fullscreen mode

Check attribute if ---i--- exit that means it's immutable

lsattr /home/bdcommerce/conf/web/bdcommerce.app/

Enter fullscreen mode Exit fullscreen mode

Thanks 💚
N I Rimon

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay