从运行nginx进程转储conf

时间:2012-10-11 04:03:45

标签: linux configuration process nginx dump

是否可以通过运行的nginx进程获取nginx使用的conf?

获取conf文件路径。有时ps aux会透露它,有时则不会。它可能只是nginx: master process /usr/sbin/nginx(与/proc/PID/cmdline相同)

  1. nginx -V是唯一的解决方案吗?
  2. this question,是否可以直接从nginx进程转储conf数据结构?或者至少转储conf文件路径?

1 个答案:

答案 0 :(得分:46)

从Nginx 1.9.2开始,你可以使用-T标志转储Nginx配置:

  

-T - 与-t相同,但另外将配置文件转储到标准输出(1.9.2)。

来源:http://nginx.org/en/docs/switches.html

这与特定进程的转储不同。如果您的Nginx正在使用不同的配置文件,请检查ps aux的输出并使用它提供的任何内容作为二进制文件,例如如果它给出类似

的东西
nginx: master process /usr/sbin/nginx -c /some/other/config

你需要运行

/usr/sbin/nginx -c /some/other/config -T

如果您还没有使用1.9.2,可以使用gdb转储配置: