📜 ⬆️ ⬇️

Installing node.js on a VPS

In this article I will tell you what problems will have to be solved in order to get a VPS with a really working node.js service. These are all basic things, but maybe someone else will come in handy.

Install node


Problem: the repository may not have a package for the correct node version. Alternatively, you may have two projects that require different versions of the node.
Solution: on development machines in such cases use nvm. On the combat server, it can also be easily used, just have to write a special script to start your server.

Access to port 80


Problem: the application must have superuser rights in order to read port 80 (for details, see CAP_NET_BIND_SERVICE, man capabilities ). But launching a node with such rights is considered unsafe.
Solutions:


Load balancing


Problem: node is single-threaded and cannot effectively use multi-core processors.
Solutions:

')

To use node directly or through Nginx?


The question was discussed a lot where, but there is no consensus On the one hand, nginx is a reliable, proven solution over the years; on the other hand, node itself is able to do the same.

As a rule, one of those options is offered:


Restart of the fallen process


Problem: how to restart the server if it suddenly falls?
Solutions:


Updating a service with git


Described here

Source: https://habr.com/ru/post/153059/


All Articles