VPS: Deploy nodejs app on cPanel (& Shared Hosting)
HTML-код
- Опубликовано: 4 ноя 2024
- Tutorial: How to Deploy Node.js backend server on VPS with cPanel
In this example my backend listens on a port and connects to mongoDB
cPanel reseller Hosting: www.a2hosting....
TEST NODE app: github.com/Pet...
STUDY TRACKER:
webdevpathway....
great but can you also install nodejs trough ssh? once the connection to the vps server is done?
Yes, you don't need cPanel to install node.js. There should be other tutorials online for that setup.
how to connect mongodb to the cPanel app hosted? before hosting i was using the connection option from mongo with vscode
In my example I used a connection string (works the same with dev mode and production). But your hosting provider must open the port 27017 so the mongoDB can connect with your server. I explained it here ruclips.net/video/sIcy3q3Ib_s/видео.html
@@peta-stewart i think that video is outdated
@@fratele_nitaa481 What is your issue with connecting to mongoDB then? I have demonstrated in this video the deployment method using the application manager. and both methods require the port 27017 to be open. Have you confirmed your hosting provider has done this? What is your error message?
@peta how can i connect my frontend tom my backend for me to post a json data
After your app is deployed and connected to your domain (as show in the video), then you send a fetch request to the route that you should have already set up. For example const response = await fetch(`yourdomain.com/route`, {
method: "POST",
headers: {"Content-Type" : "application/json"},
body: formData
})