时间:2021-07-01 10:21:17 帮助过:42人阅读
The way nginx and its modules work is determined in the configuration file. By default, the configuration file is named nginx.conf and placed in the directory /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx.
以下内容为nginx启动,关闭,重载配置文件的相关操作
To start nginx, run the executable file. Once nginx is started, it can be controlled by invoking the executable with the -s
parameter. Use the following syntax:
nginx -s signal
Where signal may be one of the following:
stop
— fast shutdownquit
— graceful shutdownreload
— reloading the configuration filereopen
— reopening the log filesFor example, to stop nginx processes with waiting for the worker processes to finish serving current requests, the following command can be executed:
nginx -s quit
This command should be executed under the same user that started nginx.
Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted. To reload configuration, execute:
nginx -s reload
Once the master process receives the signal to reload configuration, it checks the syntax validity of the new configuration file and tries to apply the configuration provided in it. If this is a success, the master process starts new worker processes and sends messages to old worker processes, requesting them to shut down. Otherwise, the master process rolls back the changes and continues to work with the old configuration. Old worker processes, receiving a command to shut down, stop accepting new connections and continue to service current requests until all such requests are serviced. After that, the old worker processes exit.
一旦启动了nginx,就可以通过nginx -s [signal]命令的方式来控制nginx.其中[signal]可以为如下的命令:
stop
— 快速停止quit
— 平滑关闭reload
— 重新加载配置文件reopen
— 重新打开日志文件nginx -s quit
当配置文件被更改,只有当nginx被重启或者接收到重载配置文件的命令时新的配置才会生效,为了更改配置文件后生效,可以使用
nginx -s reload
一旦master进程接收到重载配置文件的信号,它首先会检查新的配置文件是否有语法错误,如果没有错误,master进程将会采用新的配置,并启动新的worker进程,同时通知旧的worker进程让他们停止工作。否则,若配置文件存在错误,那么master进程仍然使用旧的配置,并且旧的worker进程将继续保持工作。一旦master进程通知worker进程停止工作,worker进程首先会停止接收链接,然后处理完当前的所有请求,之后再exit,结束执行。
以上就介绍了nginx基本介绍(基于官方文档),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。