basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    Applying nginx config changes — always nginx -t && reload, never restart

    systemctl restart nginx kills the processes, drops active downloads and WebSocket connections, and leaves the server down if the config has a typo. Running sudo nginx -t && sudo systemctl reload nginx checks syntax first and swaps workers via a zero-downtime reload.

    Why reload is safe

    When you run systemctl reload nginx, the master process receives SIGHUP, re-parses the config, spawns new workers with the updated rules, and tells the old workers to finish open requests and exit (Install & layout).

    If the config has a typo, nginx -t exits non-zero and the command after && never runs. Even if you run reload without -t, master logs the error to error.log and keeps the old workers serving traffic — sites stay up.

    # Daily command for applying config changes
    sudo nginx -t && sudo systemctl reload nginx

    If it doesn’t work

    After systemctl restart nginx, every site on the server is down and won’t come back up

    Cause
    The new config had a syntax error: restart stopped the old workers, and the new ones failed to start.
    Fix
    Find the exact failing line with sudo nginx -t, fix it, and run sudo systemctl start nginx.

    Added the nginx user to a new group (www-data) and ran reload, but Permission denied persists

    Cause
    A reload doesn’t restart the master process, so it never re-reads supplementary groups from /etc/group.
    Fix
    For group changes or a new binary after apt upgrade, run a one-off sudo systemctl restart nginx (PHP-FPM).