I have taken git clone in /var/www/html/project on server(apache) . I have started nodemon/pm2 start/ npm start it's running on the putty terminal but when I access through global IP with a port number it can not run on the system... Plz help how can we r## Heading ##un the node app on the server
Asked
Active
Viewed 189 times
1 Answers
0
Take a look at this. https://stackoverflow.com/a/26224204 There the accepted answer suggests to use proxypass to route node through apache. Why do you want to run nodeJS on an apache server anyways? Node can run independently

RomanHDev
- 104
- 5
-
how can we run node js application on a server in which directory I have to take clone ......so that we can access global like http://ip-address:3000. can u guide me – Chandra Shekharan Apr 20 '19 at 06:11
-
To my understanding the problem is, that your apache server is occupying the port on which your node app is trying to run and hence you cannot access it from the outside because you will be directed to port 3000 of your apache server. I‘ll double check and will post an answer with code to this – RomanHDev Apr 20 '19 at 06:40
-
you actually have a couple of issues here. First of all i personally would not place my node app inside of apaches file structure but outside of apache. And then just follow the steps in the link i provided. You basically have to tell apache that port 3000 does not belong to it and create a proxy route using the ProxyPass directive in the https.conf file of your apache server – RomanHDev Apr 20 '19 at 07:33
-
No sir i have try enough as possible, i kept node project outside apche root folder i also define proxy_http in apache site-available folder and i started with pm2 start all but it can't response in the browser itshowing in browser site can't reachable and i have also allow port 3000 in firewall – Chandra Shekharan Apr 21 '19 at 06:51
-
could you maybe provide provide some code in your question. For example how have set up your node app – RomanHDev Apr 21 '19 at 07:31
-
i have attached virtual host of acpache where i have define all ... i have setup project in /var/www/html ```const http = require('http'); const hostname = '162.241.222.42'; const port = 8000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('This is the Main App!\n'); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); });``` – Chandra Shekharan Apr 22 '19 at 19:01