简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM