Local Multi-Site Setup

The home server (outpost-pi, 192.168.68.54) runs Nginx + PHP 8.4 and serves multiple local websites, each with its own .lan domain.

How it works

  • Each site gets its own Nginx virtual host with a unique server_name (e.g. site1.lan)
  • Each site lives in its own directory under /var/www/ (e.g. /var/www/site1.lan/)
  • Client devices resolve .lan domains via manual /etc/hosts entries — no local DNS server needed
  • The default vhost remains as a catch-all, serving /var/www/ for anything that doesn't match a specific site

Creating a new site

A helper script is installed at /usr/local/bin/newsite:

sudo newsite myproject

This:

  1. Creates /var/www/myproject.lan/ with a placeholder index.html
  2. Writes an Nginx vhost config to /etc/nginx/sites-available/myproject.lan
  3. Symlinks it into sites-enabled
  4. Tests the config and reloads Nginx

Vhost template

Each generated config looks like this:

server {
    listen 80;
    listen [::]:80;

    server_name myproject.lan;
    root /var/www/myproject.lan;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
    }
}

Client DNS setup

On each device that needs to access local sites, add entries to the hosts file pointing to the server:

Linux / Mac/etc/hosts:

192.168.68.54  site1.lan
192.168.68.54  myproject.lan

WindowsC:\Windows\System32\drivers\etc\hosts:

192.168.68.54  site1.lan
192.168.68.54  myproject.lan

Then visit http://site1.lan in a browser.

Each new site requires a new hosts entry on every client device. If this becomes tedious, consider running dnsmasq on the server with address=/lan/192.168.68.54 to wildcard-resolve all .lan domains, and pointing clients to the server as their DNS.