Chriskuei Keep calm and code on

Deploy Node.js on Ubuntu

Start to creat your own site.

Install Node.js

$ sudo apt-get install nodejs

the nodejs package contains the nodejs binary as well as npm. You can run node -v and npm -v to see the version.

Install PM2

PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.

Run this command to install PM2:

$ sudo npm install -g pm2

PM2 usage:

$ pm2 start app.js
$ pm2 monit
$ pm2 list
$ pm2 stop    
$ pm2 restart 
$ pm2 delete  

Install Nginx

Install Nginx using apt-get:

$ sudo apt-get install nginx

Modify nginx config:

$ sudo vim /etc/nginx/nginx.conf


upstream riki {
	server[YOUR PORT];

server {
	listen 80;
	server_name localhost;
	location / {
		proxy_pass http://riki;

save and exit.

Next, restart Nginx:

$ sudo systemctl restart nginx

Enjoy your website~