/ ubuntu

save Install of node.js on Ubuntu

install nodejs as you would normaly do, apt-get, extra repo or compile it by yourself

after that create a new user and set the Homedirectory (here /node).
all my nodeapplications are located under /node
i think something like /var/www/node would be cleaner

useradd -s /bin/bash -m -d /node -c "node.js" node

now this user needs the right to open port 80 or any other privileged port you want. there are several ways, mine is to install libcap2 and give the application the right

apt-get install libcap2-bin

give the node binary the right:

setcap cap_net_bind_service=+ep /usr/bin/nodejs

install pm2, a node application to manage node applications ;-)

npm install pm2 -g --unsafe-perm

set it up to startup on boot and run the applications as user node

pm2 startup -u node ubuntu

now switch to user node an start your application and save these states for reboots

su - node
NODE_ENV=production pm2 start blog.js
pm2 save

thats it, play a little with pm2, its really nice, try some of these:

pm2 status
pm2 monit
pm2 logs
pm2 restart blog
pm2 delete blog
save Install of node.js on Ubuntu
Share this