A Node.js server for localhost environment.
$ cd node-localhost-server
$ npm install
$ node server.js
Now the localhost already started using ports 80 and 443.
Inside the root directory, there is a directory named projects. This directory is where you will put all your projects.
You can still configure vhosts (see server.js
with examples). Don't forget to configure your hosts file like:
# LOCALHOST
127.0.0.1 example.com example.com.br
If you have some problems with ports on Linux, you can run:
# Enable your user to run node apps on the default HTTP port (80)
$ sudo apt-get install libcap2-bin
$ sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``
Consider use PM2
You can start the server with:
$ pm2 start server.js