Can't find my node js and express project url - node.js

I have a node and express project and put it on cpanel. Now I can't access its url.
The path of my project I put in cPanel: public_html > backend.
And the path I want to access from my browser:
https://mydoamin/backend/apiV1/getGender
And I also tried this path:
https://mydomain/apiV1/getGender
Unfortunately, I do not have access to any of them.
NOTE: The server I use is VPS with CentOS7 operating system.
Thank you for your cooperation.

PROBLEM SOLVED
I used pm2 to run the program and now it works fine because the server is running temporarily and it is necessary to use pm2. Because it helps to keep the server running permanently.

Related

How to run Node Js application on apache server

So the problem is i'm running spring boot project on a linux server. So, on that server
the URL of that project is - https://project-name
Now i want to install a Node js project on same server
Node js project link- https://github.com/WPS/domain-story-modeler
The node js project is running on 9013 port
So, if someone hit the https://project-name/domain-story-modeler it should redirect to node js project
for that i have used reverse proxy of apache which will redirect to node js project
ProxyPass /domain-story-modeler http://localhost:9013
ProxyPassReverse /domain-story-modeler http://localhost:9013
And i run the node js project using pm2
pm2 start "npm run dev" --name domain-story-modeler and it run
The issue im facing currently is if i hit the https://project-name/domain-story-modeler it is accessing the node js project but only able to show index.html file and unable to access rest of the file like css , js, images and all
So, i want to know why is these happening.
If you want more details about issue i can provide
Thanks guys ,
But i found the solution
The issue was the url i was hitting is https://project-name/domain-story-modeler
and image tag in index.html file has path from logo folder
when i updated it with the project folder everything start working

React JS Front-end & Node js Server deployment on shared hosting

I am working on react js project & using node js for backend(to handle DB as well as to run CRON JOBs). At my local machine I had created 2 folders "botclient" & 'botserver". I starts the server using "node server.js" in 1 command prompt & in another command prompt, I satrs client using "npm start". Now in browser I use "http://localhost:3000 & my application works.
Now my client has given me 1 shared hosted domain something like http://mybot.hismaindomain.in.
Now he has given me cPanel credentials to deploy this app. I have no idea how should I deploy it on server. I had tried lots of threads like "running nodejs react in one directory" or "react js nodejs deployment on hosted server" But I could not deploy the application on Hosted server.
I am total newbie in this technology so please help me to solve this problem. Whether I am doing wrong folder structure? Whether I need 2 sub domains?(for client and server separately)
Please help me. Thanks in advance.
(This should be a comment but I csan't comment yet)
Maybe try using cPanel cron job to run the node command
You do not need two sub-domains. Neither do you need a specific folder structure to have shared hosting.
To run node two or more servers on the same host, from the same repository, from just one command line, you can use a package like 'concurrently' or 'npm-run-all', which lets one npm start-command activate a number of processes in parallell. For example: concurrently \"node server.js --port 4000\" \"webpack --config client/webpack.config.js --port 3000\" \"node cron-jobs.js\". In this example, the server is in the project root, and the react app is in client subfolder with its own package.json.
Then, to share a domain it is necessary to setup a reverse proxy, so that the backend's port can be accessed via a designated path, ie: /api. There are many ways to do it and there are others who would explain it better than me. Try google react node config reverse proxy or similar. Good to know is that the easiest solutions might be limited to a dev server, while the more complicated ones (like nginx) are independent on your tech stack (which you might not need).
For cron jobs, you could try a package like 'node-cron', check this guide for the basics

Static HTML/CSS/JS front end & Node.js back end on a live server... HOW?

I hope one of you can help me with this since I'm really struggling:
I have developed a static website locally (on Ubuntu 20.04). The website uses a node.js file (app.js) and some node nodules.
Locally the app.js lives outside the "public" folder along with the package.json and the node modules. When I run "npm run dev", the file spins up a virtual server (localhost:5000).
For the static site to be able to use the stuff inside of the app.js (sending emails with nodemailer, and connecting to mailchimp via the mailchimp api), I have to access the site through the localhost:5000.
EDIT: In my html-files, I have a form that POST to the endpoint '/subscribe', an endpoint that is picked up by the app.js file for further processing by express, and the mailchimp api.
When I'm on local, everything works as it should.
Now to the question: How do I make this work on a live server?
The static files are online in a "public" folder on the server and the front end works fine.
EDIT: I'm on a VPS running Ubuntu 20.04, Openlitespeed and the latest versions of node and npm.

Angular-universal - Production Issues

I have created Angular-universal app with reference to this Angular GitHub Repository. I have used node express for server-side rendering.
I have built using this command
npm run build:prod:ngc
now I got the client and the server folder in the dist folder. No other files there like index.html.
Previously I developed the angular2 app using CLI, on building that it create a dist folder with bundle.js, index.html, and CSS files. I used to upload that particular thing to shared hosting. The app was working fine. But in angular universal I am confused. I am stuck on how to proceed further for production. I have the shared hosting, Please help me how to host the project in shared hosting.
With universal you have to set up the server first and then start the server to listen at some port(80 normally :P)..
normally.. once you setup the node server on the hosting area, you can just go to your source code and start the server using cmd:-
sudo PORT = 80 npm run server (if ubuntu)
to listen at port 80 and then you can access the site then using IP/domain name.

Running Node JS app like PHP in apache

I have a VPS under CentOS 6.7 and I have the folder public_html in my root directory and I have an express application in a folder called cms.
Right now I have to start my server by going to the the folder where my app is located : public_html/cms then I run the node js server using the command node app.js so my question is : how can I keep my node js app running always like PHP applications in apache? I also what to be able to modify my files using FTP and see the changes taking effect like with normal PHP applications.
Thanks

Resources