Linux 从运行 nginx 进程中转储 conf
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12832033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dump conf from running nginx process
提问by est
Is it possible to get which conf the nginx is using only from a running nginx process?
是否可以仅从正在运行的 nginx 进程中获取 nginx 正在使用的配置?
To get the conf file path. sometimes ps aux
reveal it, sometimes it doesn't. It might be just something like nginx: master process /usr/sbin/nginx
(same as /proc/PID/cmdline
)
获取conf文件路径。有时ps aux
显露,有时不显露。它可能只是类似nginx: master process /usr/sbin/nginx
(相同于/proc/PID/cmdline
)
- So is
nginx -V
the only solution? - From this question, is it possible to dump conf data structure from nginx process directly? Or at least dump the conf file path?
- 那么是
nginx -V
唯一的解决方案吗? - 从这个问题,是否可以直接从 nginx 进程转储 conf 数据结构?或者至少转储conf文件路径?
采纳答案by Gordon
As of Nginx 1.9.2 you can dump the Nginx config with the -T
flag:
从 Nginx 1.9.2 开始,您可以使用以下-T
标志转储 Nginx 配置:
-T
— same as-t
, but additionally dump configuration files to standard output (1.9.2).
-T
— 与 相同-t
,但另外将配置文件转储到标准输出 (1.9.2)。
Source: http://nginx.org/en/docs/switches.html
来源:http: //nginx.org/en/docs/switches.html
This is not the same as dumping for a specific process. If your Nginx is using a different config file, check the output for ps aux
and use whatever it gives as the binary, e.g. if it gives something like
这与特定进程的转储不同。如果您的 Nginx 使用不同的配置文件,请检查输出ps aux
并使用它作为二进制文件提供的任何内容,例如,如果它提供类似
nginx: master process /usr/sbin/nginx -c /some/other/config
you need to run
你需要跑
/usr/sbin/nginx -c /some/other/config -T
If you are not on 1.9.2 yet, you can dump the config with gdb:
如果您还没有使用 1.9.2,您可以使用 gdb 转储配置: