Skip to content
Advertisement

How to run Node.Js server from php

Hello I am trying to host my website on franceDNS which only has php support, so I would like to know how can I start my node.js server from php? If at all possible. If it is just better to change the hosting service then let me know to.

Advertisement

Answer

In theory, you could use shell_exec or similar to spawn an application written in Node.js from PHP, then use cURL to make an HTTP request to that application and relay the response to the client.

However, this would be immensely inefficient, depends on features blocked by cheap hosting, would require rewriting the application to listen on different ports so you wouldn’t get clashes from two different requests to PHP scripts at around the same time, and would lose the ability to handle anything that requires data to be stored in-memory across requests.


In short: Find suitable hosting. Don’t try to hack this.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement