是否可以仅从正在运行的 nginx 进程中获取 nginx 正在使用的 conf?
获取conf文件路径。有时 ps aux
显示它,有时它不显示。它可能类似于 nginx: master process/usr/sbin/nginx
(与 /proc/PID/cmdline
相同)
- 那么
nginx -V
是唯一的解决方案吗? - 来自 this question ,是否可以直接从 nginx 进程中转储 conf 数据结构?或者至少转储 conf 文件路径?
最佳答案
从 Nginx 1.9.2 开始,您可以使用 -T
标志转储 Nginx 配置:
-T
— same as-t
, but additionally dump configuration files to standard output (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 转储配置:
关于linux - 从正在运行的 nginx 进程中转储 conf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12832033/