Check Error Messages
sudo systemctl status nginx
sudo journalctl -u nginx -f
sudo nginx -t
Common Configuration Errors
1. Syntax Errors
nginx: [emerg] unknown directive "server_name"
2. Missing Semicolons
server_name example.com; # correct
server_name example.com # wrong
3. Duplicate listen directives
listen 80;
4. Port Already in Use
sudo netstat -tlnp | grep :80
sudo lsof -i :80
sudo systemctl stop apache2
5. Permission Issues
ls -la /var/log/nginx/
sudo chown -R www-data:adm /var/log/nginx/
sudo chmod 600 /etc/ssl/private/yourkey.key
6. Missing Includes
grep -r "include" /etc/nginx/
Port Conflict Fix
sudo fuser -k 80/tcp
sudo fuser -k 443/tcp
sudo systemctl start nginx
PID Issue
sudo rm -f /var/run/nginx.pid
sudo systemctl start nginx
SELinux Check
getenforce
sudo setenforce 0
sudo systemctl start nginx