Skip to content

Instantly share code, notes, and snippets.

@lancevo
Last active January 15, 2019 22:03
Show Gist options
  • Save lancevo/93c2ebfe9be56d7c23cdf9befc967dec to your computer and use it in GitHub Desktop.
Save lancevo/93c2ebfe9be56d7c23cdf9befc967dec to your computer and use it in GitHub Desktop.
ubuntu nginx nvm

[https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04](Install Nginx)
[https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04](Configure PM2)

sudo apt-get update -y
sudo apt-get install build-essential -y
sudo apt-get install nginx -y
sudo ufw allow 'Nginx Full'
sudo ufw status
# install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

nvm install 10.15.0
npm i pm2 -g

# launch pm2 on server boots, then follow instruction
pm2 startup systemd

# run pm2 with npm start
# pm2 start npm -- start

# genere ssh
ssh-keygen


@lancevo
Copy link
Author

lancevo commented Jan 15, 2019

nginx create a proxy create a file in /etc/sites-available/api.domain.com

server {
    listen 80;
    server_name  api.saigontoday.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
    }
} 

Link it to enable the site

sudo ln -s /etc/nginx/sites-available/api.domain.com /etc/nginx/sites-enabled

Test nginx conf

sudo nginx -t

Restart nginx

sudo systemctl restart nginx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment