>_ IzzyLab

Hands-on task

This task is step 22 of the course “Troubleshooting and recovering a Linux server”

nginx won't start after an edit

medium~7 min

Someone edited the nginx config and the service no longer comes up. Find the syntax error, fix it and start nginx so that http://localhost/ returns 200.

While nginx is down, the Site tab shows an error. Fix the config (it's easy to edit in the Editor tab), start nginx and click Refresh in the Site tab — the shop page should open.

What you'll practise:
  • nginx
  • nginx -t
  • config syntax
  • service
  • diagnostics

Topic breakdown

nginx has a built-in config check (nginx -t) that parses the config without starting and prints the exact file and line number of the error — no need to read it with your eyes. Typical bugs after a manual edit: a missing ; at the end of a directive, an unclosed or extra curly brace, a typo in a directive name; fix and rerun the check until it comes back clean, because there may be several errors. Starting in a container without systemd goes through the service wrapper or a direct call to the binary, not through systemctl; if it complains about the port being in use, look for a stale old process or pid file.

What's checked

  1. nginx config is valid
  2. Site returns 200

What it looks like