Nginx’s event-driven asynchronous architecture makes it the fastest web server for delivering static HTML, CSS, JavaScript, and media assets. This guide covers deploying a static website on Ubuntu Linux from directory setup to server block configuration.

Step 1: Create Web Directory & Set Permissions

Terminal Directory Setupbash
# Create web root directory for domain
sudo mkdir -p /var/www/mywebsite/html
 
# Set ownership to Nginx user (www-data) and current user
sudo chown -R $USER:www-data /var/www/mywebsite/html
sudo chmod -R 755 /var/www/mywebsite

Step 2: Configure Nginx Server Block

/etc/nginx/sites-available/mywebsitenginx
server {
    listen 80;
    listen [::]:80;
 
    server_name mywebsite.com www.mywebsite.com;
    root /var/www/mywebsite/html;
    index index.html index.htm;
 
    location / {
        try_files $uri $uri/ =404;
    }
 
    # Enable Gzip compression for text/CSS/JS assets
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml;
}

Step 3: Enable Site & Test Configuration

Terminal Deployment Commandsbash
# Create symlink to sites-enabled
sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/
 
# Verify syntax correctness
sudo nginx -t
 
# Reload Nginx service without downtime
sudo systemctl reload nginx