基础命令 
基本命令 
| 选项 | 作用 | 示例 | 
|---|---|---|
-?-h | 查看命令帮助 | nginx -h | 
-v | 查看版本信息 | nginx -v | 
-V | 查看版本及编译信息 | nginx -V | 
-t | 测试配置文件正确性 | nginx -t | 
-T | 测试配置文件正确性并输出配置内容 | nginx -T | 
-q | 测试配置文件时忽略非error信息 | nginx -qt/nginx -qT | 
-s | 发送信号至主进程 | nginx -s reload/stop/quit/reopen | 
-p | 指定Nginx前缀路径 | nginx -p /data/nginx | 
-e | 设置错误日志文件路径(默认logs/error.log),相对前缀路径的相对路径 | nginx -e logs/error.log | 
-c | 设置主配置文件路径(默认conf/nginx.conf),相对前缀路径的相对路径 | nginx -c conf/nginx.conf | 
-g | 设置全局指令(不能在配置文件中重复),可以使用多个-g | nginx -g 'daemon off;' -g 'worker_processes 4;' | 
信号选项 
| 名称 | 作用 | 示例 | 
|---|---|---|
reload | 重新加载Nginx配置文件,无需停止服务 | nginx -s reload | 
stop | 停止Nginx服务 | nginx -s stop | 
quit | 优雅停止Nginx服务,完成连接时停止 | nginx -s quit | 
reopen | 重新打开日志文件,用于切割日志文件 | nginx -s reopen |