Docs / Web Servers / How to Set Up Nginx Server Blocks (Virtual Hosts)

How to Set Up Nginx Server Blocks (Virtual Hosts)

By Admin · Feb 25, 2026 · Updated Apr 25, 2026 · 46 views · 1 min read

Server blocks let you host multiple websites on a single Breeze.

Create a Server Block

Create /etc/nginx/sites-available/example.com:

server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/example.com/html;
    index index.html index.php;

    location / {
        try_files $uri $uri/ =404;
    }
}

Create the Web Root

mkdir -p /var/www/example.com/html
echo "<h1>Hello from example.com</h1>" > /var/www/example.com/html/index.html
chown -R www-data:www-data /var/www/example.com

Enable the Site

ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx

Was this article helpful?