for debian and ubuntu based distros, do the following.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
replace 8
with 10
for node v10
source: https://nodejs.org/en/download/package-manager/
sudo apt install ngnix -y
Open the configuration file using
sudo nano /etc/nginx/sites-available/default
and replace everything in this block to the below code
. . .
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
change your port accordingly
Start your server using the normal commands and append & at the end of the command to make it a background process so that it does not terminate when you close the terminal.
eg: npm start &
Alternatively, start the process normally using npm start
and press CTRL/COMMAND
+Z
. Then type bg
and press enter to send the process to background. This is the same as appending &
to the command.
use pm2
for nodejs
sudo systemctl restart nginx
I use ng serve --host 0.0.0.0 --disable-host-check
to test live without building by configuring a webhook that pulls every push to github. Disable host check flag allows to access the ng serve pages on different host.