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

🎯 Mission Briefing: Port 80 Is Taken

Since this morning the company website shows "Apache2 Debian Default Page — It works!" instead of the shop. Nobody touched nginx's configuration. Yesterday, though, a colleague installed something for a small PHP script…

Your objective

Find out why nginx isn't serving the site, find which program is holding the web port, and give the port back to nginx — for good.

Investigation toolkit

curl -s http://localhost | grep -i title # What does the server answer?
systemctl status nginx                   # Is nginx running? Why not?
sudo ss -tlnp                            # Which program listens on which port?
sudo lsof -i :80                         # The same question, asked of one port
tail /var/log/apt/history.log            # What was installed yesterday?

Fix and verify

sudo systemctl stop apache2              # Free port 80
sudo systemctl disable apache2           # …and keep it free after a reboot
sudo systemctl start nginx
curl -I http://localhost                 # Server: nginx?

💡 Only one program can listen on a port. Address already in use means someone else got there first — ss -tlnp tells you who. Without sudo you see the port but not the program.

Practice tasks

  1. Find out why nginx isn't running
  2. Find which program is listening on port 80
  3. Stop the program that took the port
  4. Make sure it won't take the port again after a reboot
  5. Start nginx again

Missions