Command
sudo systemctl status nginxExplanation
Checking Nginx’s status helps verify whether the web server is running, stopped, or in a failed state. The `systemctl status` output includes the service’s PID, uptime, recent logs, and resource usage. It’s an essential step in diagnosing availability issues.
Common Use Cases
- •Confirm if Nginx is running after configuration changes
- •Diagnose service crashes or failed startups
- •Monitor uptime and reload events
Best Practices
- ✓Use `sudo systemctl status nginx -l` for full log output
- ✓Combine with `journalctl -u nginx` to view recent log history
- ✓Monitor uptime regularly in production
Common Mistakes to Avoid
- ⚠Confusing `status` with `reload` or `restart` commands
- ⚠Not running with `sudo`, leading to incomplete info
Troubleshooting
Problem: Status shows failed
Solution: Run `sudo nginx -t` to find syntax errors, then restart the service.
Problem: Service active but site unreachable
Solution: Check firewall rules and Nginx’s listening ports in config.
Examples
Check Nginx status using systemd
sudo systemctl status nginxCheck Nginx status using SysV
sudo service nginx statusMore
Reload Nginx Configuration
Reload the Nginx service configuration without interrupting connections.
Check Repository Status
Display the current state of your working directory and staging area, showing which files are modified, staged, or untracked
Check Apache Status
Check Apache service status