Where to run node.js -
so thought giving node.js try seeing possibilities has little test chat project (with mysql) i'm doing.
but couldn't find out run file , whats common.
what have:
- a freebsd server latest node , php 5.3.x
- a vhost
- some tutorials on how start node (which looked through , got exited about)
- knowledge on how run terminal without having keep terminal open (screen)
so far good.
what need:
- some basic information of put (lets say:) chat.js file.
- most logical port run on
so web root (www) runs on user (not root obviously). , webroot has underlying folder put script (away visitors grabby little hands). seems me safe place put seeing nobody can it, want seeing i'm going connect db , don't want db login data out there (i don't know how works yet i'll figure out db connect node later, no answer required).
but if file not in webroot, seems me connection cannot made outside. cause webroot configured allow 80 (or ssl on 443) incomming traffic, logical. outgoing has no problems.
all examples found don't me. on local machine, sucks me cause don't want that.
so best practice for:
- where put file
- port run on.
a lot of confusion newcomers node misunderstanding is. description on nodejs.org doesn't help.
an important thing realize node not webserver. doesn't anything. doesn't work apache. there no config file point html files. if want http server, have write http server (with of built-in libraries). node.js way execute code on computer. javascript runtime.
a nice tutorial how deploy node js applications, examples
you'll need have non-node application on port 9000 (for apache, in /etc/apache2/ports.conf , in sites-available file site), , you'll need node application listen on 8080. you'll need set dns 'a' records different hostnames you'll using servers.
companies heroku allow automated deployment of apps desktop cloud. nodejitsu provides tool called jitsu makes deploying node.js application super simple. can install jitsu npm.
npm install jitsu -g
heroku how to getting started jitsu
use monit, forever, upstart or systemd start node server. use varnish or haproxy or nginx (nginx not work websockets).
Comments
Post a Comment