Something broke: the web server won’t start
A troubleshooting challenge: someone edited the web server’s config and now nginx won’t start. Find the error, fix the file and bring the site back.
Someone tidied up the web server's config last night. This morning http://web/ doesn't answer, and restarting nginx "didn't help". Find out why and get the site back, without guessing. The checklist only ticks when it really works.
A few things worth knowing before you start:
- A service that fails to start writes why to the journal.
systemctl status nginxshows the last lines;sudo journalctl -u nginxshows more. sudo nginx -tchecks the config files without touching the running server. Run it before every restart and you'll never take a working site down with a typo.- Config files under
/etcbelong to root, so edit them withsudo vim. - Programs report where they noticed a problem, which isn't always where you made it.
web is a pretend server inside this page. Reset puts everything back as it was.
Your turn
Get http://web/ answering again, with a config that nginx -t passes.
Your task
Get http://web/ answering again, with a config that nginx -t passes.
- Find the error message (not done yet)
- nginx -t says the config is fine (not done yet)
- The site answers again (not done yet)
The checklist ticks itself off as you work in the terminal: any way that gets the result counts.
Hints come one at a time, then one way to do it. Try each before the next.
What this lesson uses, in one place.
systemctl status- Is it running? recent log lines More on systemctl
journalctl -u- Only this service More on journalctl
nginx -t- Test the configuration
vim- Edit text files in the terminal (a practice subset of Vim) More on vim
Every everyday command on one page: the Linux commands cheat sheet.