1. nginx进程控制
nginx
启动后,可以通过以下语法对nginx
进行开启/关闭等操作:
$ sudo nginx -s [参数]
1
参数:
stop
— 立即停止(fast shutdown
)quit
— 等worker process
完成请求服务再终止进程(graceful shutdown
),($ kill pid
==nginx -s quit
)reload
— 重启(reloading the configuration file
)reopen
— 重新打开日志文件(reopening the log files
)
另外,也可以通过kill
来终止nginx
。
// 查看nginx pid -- 方法1
$ cat /var/run/nginx.pid 或 /usr/local/nginx/logs/nginx.pid
pid: 910
// 查看nginx pid -- 方法2
$ ps -ax | grep nginx
910 ? Ss 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
935 ? S 0:00 nginx: worker process
936 ? S 0:00 nginx: worker process
// 终止nginx: master process
$ kill -s QUIT 910
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
2. 文件配置
2.1 配置文件位置
/etc/nginx/
/usr/local/nginx/conf/
/usr/local/etc/nginx/nginx.conf
2.2 配置文件结构
