Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I need to run a node.js script on my server?

I have a standard Apache server. Do I need anything special to run a node.js script (http://socket.io/) on the serverside?

like image 714
Andy Hin Avatar asked Feb 10 '11 22:02

Andy Hin


People also ask

How do I run node js on my server?

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.

How do I run a node js script?

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.

Do you need a server to run node JS?

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.

CAN node JS run on any server?

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.


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.

like image 88
Stoive Avatar answered Oct 03 '22 12:10

Stoive


You will need shell access to start the node.js server. So it most likely won't work on shared hosting.

like image 39
ThiefMaster Avatar answered Oct 03 '22 12:10

ThiefMaster