Intermediate · 15 min · practise every command in the built-in terminal

🎯 Mission Briefing: One Missing Character

Marko added the new web shop to nginx, restarted the server and left for a two-week holiday. Since then every site on this server is down. Nobody else knows nginx — so it's on you.

Your objective

Find out why nginx won't start, locate the exact broken line, fix it, and bring the web server back.

Investigation toolkit

cat ~/handover.txt                   # What did Marko change?
systemctl status nginx               # Is nginx running? Since when not?
journalctl -u nginx -n 20            # The error from the failed start
sudo nginx -t                        # Test the configuration: which file, which line?
cat -n /etc/nginx/conf.d/shop.conf   # Look at the file with line numbers

Fix and verify

sudo nano /etc/nginx/conf.d/shop.conf      # Fix the line nginx -t points at
sudo nginx -t                              # Test again until it says "syntax is ok"
sudo systemctl restart nginx
curl -I http://localhost

💡 Always run sudo nginx -t before restarting nginx. A restart with a broken config takes down every site on the server; nginx -t costs nothing.

💡 An error on line N is often caused by the line before it — nginx reads until it finds the ; that ends a directive.

Practice tasks

  1. Find out why the website is down
  2. Test the nginx configuration to find the broken line
  3. Fix the error in /etc/nginx/conf.d/shop.conf
  4. Test the configuration again until it passes
  5. Start nginx again

Missions