Ravindra BagaleCourses & study guides

Chapter 8: Configuring Nginx and Apache

8.10 Troubleshooting configuration problems

Symptom Likely cause Fix
403 Forbidden after changing root New folder outside /var/www without <Directory>/permissions; SELinux label wrong namei -​l /​path/​index.​html; add <Directory> with Require all granted; CentOS: semanage fcontext + restorecon -Rv
Default welcome page instead of your site Another block is default_server / loads first; server_name doesn't match sudo nginx -​T | grep -​E "server_​name|​listen"; sudo apachectl -​S; remove Ubuntu default / 000-default
nginx -t: unexpected "}" or directive is not terminated Missing ; or { Fix the line before the one reported
Invalid command 'Require' or '#' Typo or inline comment in Apache Put comments on their own line; check spelling
Service fails on new port: Permission denied SELinux port not allowed (CentOS) semanage port -​a -​t http_​port_​t -​p tcp PORT
New port not reachable from browser Security group / firewalld not opened Add inbound rule; firewall-​cmd --​add-​port
Address already in use Both Nginx and Apache on port 80 sudo ss -​tlnp | grep :​80; stop one
Changes have no effect Not reloaded; edited a .bak or wrong file sudo nginx -T shows what is really loaded
Downloads PHP file instead of running it PHP handler not configured See Chapter 10 (PHP-FPM)