Deploying a Static Website with Nginx

This guide walks through how to deploy a static website on a cloud server using Nginx.

Step-by-Step Guide

  1. Step 1: Install Nginx

    First, install Nginx on your cloud server:

    sudo apt update
    sudo apt install nginx
  2. Step 2: Upload Your Website Files

    Use the scp command to securely copy your local files to the Nginx web directory:

    scp -r /local-path-to-your-site/* user@your-server-ip:/var/www/html/
  3. Step 3: Set Permissions

    Ensure the correct permissions are set so that Nginx can serve the files:

    sudo chown -R www-data:www-data /var/www/html/
    sudo chmod -R 755 /var/www/html/
  4. Step 4: Reload Nginx

    After uploading and setting permissions, reload Nginx to apply the changes:

    sudo systemctl reload nginx