I have a standard Apache server. Do I need anything special to run a node.js script (http://socket.io/) on the serverside?
2 Answers
Node.js provides its own HTTP server, thus making Apache unnecessary.
If you wish to run Apache and Node.js on the same server, either set node to listen to port 80 and forward unhandled requests to Apache, or vice versa
In both instances, Node/Apache will listen to the publicly open port 80, and forward to Apache/Node listening on some non-public port.
2 Comments
anarkhos
Thank you very much for that information. A question, please. It seems to me that it makes more sense from a performance perspective to use Node/Apache instead of Apache/Node. (assuming that 50% of requests go to Node.js, and 50% to Apache.) Is that true?
Stoive
In my opinion, yes, that is true. Node likely has a much shorter 'path' than Apache for offloading requests as early as possible. Always worth some performance testing, though.
You will need shell access to start the node.js server. So it most likely won't work on shared hosting.
2 Comments
Andy Hin
I have a virtual private server with shell access.
ThiefMaster
Then you can simply install node.js. How you do it depends on your distribution (unless you want to compile from source) and if you have questions about it, better ask them on serverfault.com