I have a standard Apache server. Do I need anything special to run a node.js script (http://socket.io/) on the serverside?
The usual way to run a Node. js program is to run the globally available node command (once you install Node. js) and pass the name of the file you want to execute. While running the command, make sure you are in the same directory which contains the app.
You can Run your JavaScript File from your Terminal only if you have installed NodeJs runtime. If you have Installed it then Simply open the terminal and type “node FileName. js”. If you don't have NodeJs runtime environment then go to NodeJs Runtime Environment Download and Download it.
Strictly speaking, you don't need to put a web server on top of Node. js - you can write a small server within your Node project and have that handle all routine browser requests as well as those particular to the web app concerned.
You can have multiple Node services running in a cluster depending on how many processors your machine has etc. So to recap - your front facing web server will be handling all traffic on port 80 (HTTP) and or 443 (HTTPS) and this will proxy the requests to your Node service running on whatever port(s) you define.
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.
You will need shell access to start the node.js server. So it most likely won't work on shared hosting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With