tags:
- nginx
- notes
- servers
- software
- article
source: http://nginx.org/en/docs/beginners_guide.html
What processes does NGINX have?
NGINX has one master process and several worker processes.
What is the purpose of NGINX's master process?
The purpose of NGINX's master process is to read and evaluate configuration, and maintain worker processes.What is the purpose of NGINX's worker processes?
The purpose of NGINX's worker processes is to actually process requests.What techniques does NGINX employ to distribute requests among the worker processes?
To distribute requests among the worker processes, NGINX employs event-based model and OS-dependent mechanisms.What's the number of worker processes NGINX starts?
The number of worker processes NGINX starts can either be defined in the configuration file or automatically adjusted to the number of CPU cores.
What is the name of NGINX's configuration file?
The name of NGINX's configuration file is nginx.conf
.
What are the three directories NGINX's configuration file,
nginx.conf
, can be placed by default?
The three directories NGINX's configuration file,nginx.conf
, can be placed by default are:
/usr/local/nginx/conf
./etc/nginx
./usr/local/etc/nginx
.
How do you send a signal to NGINX's master process with the nginx
executable?
To send a signal to NGINX's master process with the nginx
executable, run:
nginx -s signal
What signals are available to send to NGINX with the
nginx
executable?
The signals available to send to NGINX with thenginx
executable are:
stop
- Fast shutdown.quit
- Graceful shutdown.reload
- Reload the configuration.reopen
- Reopen the log files.What does NGINX do when it receives a signal to reload the configuration?
Once NGINX receives a signal to reload the configuration, it checks the syntax validity of the new configuration and tries to apply it.What does NGINX's master process do when the reloaded configuration is valid?
If the reloaded configuration is valid, NGINX's master process starts new worker processes and sends messages to old worker processes to shutdown.What does NGINX's master process do when the reloaded configuration is invalid?
If the reloaded configuration is invalid, NGINX's master process rolls back the changes and continues with the old configuration.
How do you send a signal to NGINX's master process with the kill
utility?
To send a signal to NGINX's master process with the kill
utility, run:
kill -s SIGNAL PID
Where can you find the PID of NGINX's master process in the file system?
You can find the PID of NGINX's master process in the file system by reading thenginx.pid
file, which is either in the/usr/local/nginx/logs
or/var/run
directories.How can you find the PID of NGINX's master process with the
ps
utility?
To find the PID of NGINX's master process with theps
utility, run:ps -ax | grep nginx
What does NGINX consist of?
NGINX consists of modules controlled by directives specified in the configuration file.
What are the two types of directives in NGINX's configuration file?
The two types of directives in NGINX's configuration file are:
- Simple directives.
- Block directives.
In NGINX's configuration file, what does a simple directive consist of?
In NGINX's configuration file, a simple directive consists of a name and parameters separated by spaces, and ends with a semicolon.In NGINX's configuration file, what does a block directive consist of?
In NGINX's configuration file, a block directive consists of the same structure as a simple directive but it ends with a set of additional instructions surrounded by braces instead of a semicolon.In NGINX's configuration file, what is a block directive that can have other directives inside braces called?
In NGINX's configuration file, a block directive that can have other directives inside braces is called a context.In NGINX's configuration file, what context are directives in if they're placed outside any context?
If directives are placed outside any context in NGINX's configuration file, they're in themain
context.In NGINX's configuration file, what context do the
events
andhttp
directives reside?
In NGINX's configuration file, theevents
andhttp
directives reside in themain
context.In NGINX's configuration file, what context do the
server
directives reside?
In NGINX's configuration file, theserver
directives reside in thehttp
context.In NGINX's configuration file, what context do the
location
directives reside?
In NGINX's configuration file, thelocation
directives reside in theserver
context.
How are server
contexts distinguished?
Server contexts are distinguished by what ports they're listening on and server names.
What does NGINX do once it decides which server
context processes a request?
Once NGINX decides which server
context processes a request, it tests the URI from the request's header against the parameters of the location
directives in the server
context.
What does NGINX do if multiple
location
directives match the URI?
If multiplelocation
directives match the URI, NGINX prefers the one with the longest prefix.What does NGINX do if a
location
directive with a regular expression matches the URI?
If alocation
directive with a regular expression matches the URI, NGINX prefers it over thelocation
directive with the longest matching prefix.
What two log files can you check if NGINX's configuration doesn't work as expected?
If NGINX's configuration doesn't work as expected, two log files you can check are:
access.log
.error.log
.What are the two locations that NGINX logs could be stored at?
The two locations that NGINX logs could be stored at are:
/usr/local/nginx/logs
./var/log/nginx
.
What is a proxy server?
A proxy server is a server that receives requests, passes them to the proxied servers, retrieves the responses from them, and sends them to the clients.
What NGINX directive and parameters are used to pass a request to another server?
The NGINXproxy_pass
directive, along with the protocol, name, and port of the proxied server, are used to pass a request to another server.
What should regular expressions in location
directives be preceded by?
Regular expressions in location
directives should be preceded by ~
.
How do you write a regular expression which matches URIs ending with particular file extensions?
To write a regular expression which matches URIs ending with particular file extensions, write:location ~ \.(extension1|extension2)$ { ... }
What directive and parameters are used to pass a request to a FastCGI server?
The fastcgi_pass
directive, along with the name and port of the FastCGI server, are used to pass a request to another server.
What directives are used to set parameters that are passed to the FastCGI server?
The directives used to set parameters that are passed to the FastCGI server arefastcgi_param
directives.