nginx -v
nginx -t
nginx -s stop // 强制停止
nginx -s quit // 优雅:先正常处理当前所有请求再停止
- nginx -s SIGQUIT <nginx master pid>
- nginx -s SIGWINCH <nginx worker pid>
nginx -s reload // 先优雅关闭,再重新启动
- nginx -s SIGHUP <nginx master pid>
nginx -s reopen // 重新打开日志文件
// 可以先把当前日志改名或迁移备份,再 reopen 打开生成新日志文件
- nginx -s SIGUSR1 <nginx master pid>
kill -s SIGUSR2 <nginx master pid>
nginx
nginx -c /etc/nginx/nginx.conf
nginx -p /usr/local/nginx/
nginx -g 'pid /var/nginx/test.pid'
(对应操作-g, eg: nginx -g 'pid /var/nginx/test.pid' -s stop
)nginx -s SIGQUIT <nginx master pid>
Nginx 通常由一个 master 进程来管理多个 worker 进程, 通常默认配置为: /etc/nginx/nginx.conf
一般配置块 block{} 有: http / server / location / upstream / if
daemon on | off
(当用 gdb调试进程时需要停止守护来跟进 fork 出的子进程)worker_rlimit_core size
worker_rlimit_sigpending limit
woker_connections <int:number>
worker_rlimit_nofile limit
access_log /var/log/nginx/access.log
error_log /var/log/nginx/error.log
(可以通过修改 /etc/logrotate.d/nginx
设置日志的大小等)debug_connection [IP|CIDR]
必须在 events
模块里events {
debug_connection 127.0.0.1;
debug_connection 172.28.36.0/24;
}
建议worker 数量和服务器的 CPU 核心数一样,且一一绑定, 减少进程间切换的代价。
worker_processes 4;
worker_cpu_affinity 1000 0100 0010 0001;
use [ epoll | select | poll | rtsig | eventport | /dev/poll ];
linux 可供选择 epoll poll select 三种,epoll 性能最好。下一章: Nginx 2. location 和 http_proxy
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。