About this chapter
This chapter opens up the nginx configuration files. You will learn where nginx.conf lives and how it is laid out, what directives and contexts are, how include splits config into conf.d/ and sites-available, how to test a config with nginx -t before every reload, and how to read the access and error logs when something breaks.
Lessons from courses
- 1 The nginx.conf config file structure Find the nginx.conf file location on Linux, learn its default path and structure, and read the file at a glance before you edit it.
- 2 Directives and contexts in nginx Learn nginx directives and contexts - simple vs block directives, main/events/http/server/location, and how nesting and inheritance work.
- 3 include, conf.d and sites-available Nginx sites-available vs sites-enabled explained, plus the include directive and conf.d folder for keeping each site in its own file.
- 4 Testing nginx config safely with nginx -t Run nginx -t to test your nginx config before reload. Learn reload vs restart, what a syntax error looks like, and how to avoid downtime.
- 5 Reading nginx access and error logs Where nginx access and error logs live, what error log levels mean, and how to tail them to debug problems in real time.