Skip to content

Instantly share code, notes, and snippets.

@mgmgpyaesonewin
Last active March 14, 2019 11:40
Show Gist options
  • Save mgmgpyaesonewin/97d670e2a953ee17f401d71d30e0058e to your computer and use it in GitHub Desktop.
Save mgmgpyaesonewin/97d670e2a953ee17f401d71d30e0058e to your computer and use it in GitHub Desktop.
Ubuntu / Nginx / PM2 / Nodejs installation

Nginx

Install

  • sudo apt-get install nginx

CMD

  • sudo systemctl status nginx
  • sudo systemctl start nginx
  • sudo systemctl restart nginx
  • sudo nginx -t # Check nginx syntax.

CONFIG

server {
    listen 80;
    listen [::]:80;
    index index.html;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
        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;
    }
}

PM2

Install

  • sudo npm install pm2 -g

HTTPS Config

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot python-certbot-nginx 

After installing, nodejs & pm2 & nginx,

basic domain configuration

  • sudo cp -R default your-domain.com
  • sudo vim /etc/nginx/sites-available/your-domain.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment