How to run Node Js application on apache server - node.js

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

Related

Can't find my node js and express project url

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.

How to deploy React and Node.js on cPanel

I am asking here because I have no idea what to do anymore. I want to deploy my React app that uses Nodejs as a server and I cannot find a proper article or forum to help me. They all only talk about how to setup Nodejs or how to setup React. Nothing on how to setup both at the same time. This is my first React project with Nodejs.
I am trying to deploy my React app using a Node.js as a server onto cPanel on my domain. When adding my React build folder to public_html then the front end is good and obviously Node is not working when I try to use the backend functionalities. When I go and setup a Node.js App in my cPanel I cannot get the js script to point to server/index.js, it only selects index.js in the root. Check image below:
I point my index.js with my server config to server/index.js in my Application startup file but it keeps going to the index.js in the app, not server/index.js.
My directory is as follows:
-app
-build
-node_modules
-public
-server
-index.js (must use this one)
-src
-.env
-package.json
-index.js (keeps using this one)
How can I deploy my React app with Node server using cPanel? Please help.

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