Real Project: Deploy a Website
8 min read
Deploy a website on Linux: install Nginx, place files in /var/www/, create a server block, enable it with a symlink to sites-enabled, test with nginx -t, and get free HTTPS with certbot --nginx for your domain.
Deploy Nginx + SSL
# Install
sudo apt install nginx certbot python3-certbot-nginx
# Upload site
rsync -avz dist/ user@server:/var/www/mysite/
# Nginx config
server {
server_name mysite.com www.mysite.com;
root /var/www/mysite;
index index.html;
location / { try_files $uri $uri/ /index.html; }
}
# Get SSL cert
sudo certbot --nginx -d mysite.com -d www.mysite.com
# Auto-renew (built into certbot timer)