Nginx启动之后,可以使用以下命令控制:
nginx -s <signal>
其中-s 的意思是向主进程发送信号,signal可以为四个中的一个:
- stop:快速关闭
- quit:优雅关闭
- reload:重新加载配置文件
- reopen:重新打开日志文件。
当我运行nginx -s quit时,报错信息如下:
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2021/12/18 18:41:06 [warn] 130334#130334: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2021/12/18 18:41:06 [notice] 130334#130334: signal process started
2021/12/18 18:41:06 [alert] 130334#130334: kill(130172, 15) failed (1: Operation not permitted)
报错原因:是用户操作权限不够
解决方案:前面加上sudo后可以运行。
命令如下:
sudo nginx -s quit