0
var express = require('express')

let app = express();

app.get('/',(req,res)=>{
res.send('Hello world')
})

app.listen(3000, () => console.log('Server running on http://localhost:3000/'));

above is the simple app i want it to host on apache. everytime server start,i should be able to ping this url in browser.

i am trying below in vhost file :-

Listen 3000
<VirtualHost *:3000>
DocumentRoot  D:/myapp
 <Directory  D:/myapp>

myapp is the folder where app.js and package-json is placed.

for react app i put the build path for DocumentRoot and Directory and it works,but for express app i am not able to do.

Please help me out with vhost configuration OR any other things if need .

Bill P
  • 3,622
  • 10
  • 20
  • 32
  • Why do you want to do that?, Apache is a webserver and this express application running in a node.js environmet supposse to be a webserver as well, and it is quite comlicated to configure apache webserver and node webserver running on the same instance and machine listening on a custom port(s). – Sándor Bakos Sep 30 '19 at 22:03
  • ok... now i understand. but again:- if anything goes wrong or instance restarts ,i will need to run it again as node app.js. and also command prompt will remain open. there should be way to run the api everytime.... Actually i have made a authentication Api (with passport),which will be accesed by a webapp (hosted on apache). andi want to host this backend api also, what should i do? – Rohit Kumar Oct 01 '19 at 09:50
  • Like apache restart automatically ,when machine restart....Means front-end is up.. there should be a way to manage express app also. – Rohit Kumar Oct 01 '19 at 09:57

0 Answers0