Well, what you need to do is understand how http web servers work.
Usually on your remote computer (on your server) an instance of the web server is running (for example: apache), which listens on port 80 (the standard port for HTTP requests). It will process every request made on this port and manage the routing to use the correct php / html file.
Then it will run the php code on the server side to display the html file and transfer it to the server. Thus, the client will not see php code at all.
Tell us about Node.js. Node is an application that runs JavaScript code on a server, and can run an http server using some modules. But the javascript code will never be shown to your client, it will receive only the HTTP response that you send to it (usually an html page).
So now with Node.js you need to do the same thing as the Apache server by creating an http server. First, you should be aware that not many website hosts offer Node.js or even console access. Usually they serve the php / html files that you put in the configured folder, and that is basically it. You will need either a virtual machine or a server on which you can install Node.js and run it, or use a Node.js hosting service, for example heroku or nodejitsu, to host your Node.js http server.
So, to create the Node.js http server, you need to create an http server (as in your code) and make it listen on port 80. Now, every HTTP request sent to your server will be processed by your Node.js. Then you can do whatever you want with this request.
I hope I was not dirty.
Clement berthou
source share