Chapter 6: Web Servers — Nginx and Apache
6.8 Everyday management commands
| Task | Nginx | Apache (AL2023/CentOS) | Apache (Ubuntu) |
|---|---|---|---|
| Test config | sudo nginx -t |
sudo apachectl configtest |
sudo apache2ctl configtest |
| Reload (no downtime) | sudo service nginx reload |
sudo service httpd reload |
sudo service apache2 reload |
| Restart | sudo service nginx restart |
sudo service httpd restart |
sudo service apache2 restart |
| Error log | sudo tail -f /var/log/nginx/error.log |
sudo tail -f /var/log/httpd/error_log |
sudo tail -f /var/log/apache2/error.log |
| Access log | /var/log/nginx/access.log |
/var/log/httpd/access_log |
/var/log/apache2/access.log |
| Version | nginx -v |
httpd -v |
apache2 -v |
| Loaded modules | nginx -V |
httpd -M |
apache2ctl -M |
Always test before reload
Use sudo nginx -t && sudo service nginx reload. The reload runs only if the test passes, so a typo never takes your site down.