当前位置:首页 > nginx > 正文

nginx查看使用的配置文件

  • nginx
  • 2024-05-03 07:24:55
  • 8479

1. 使用 nginx -T 命令
bash
nginx -T
此命令将打印出 nginx 的主配置文件以及所有包含的配置文件的完整的解析配置。
2. 使用 nginx -V 命令
bash
nginx -V
此命令将打印出 nginx 的版本信息、编译选项和已加载的模块。 它还将包括以下行:
text
built by nginx-build with config file /etc/nginx/nginx.conf
其中 /etc/nginx/nginx.conf 是 nginx 的主配置文件的路径。
3. 检查 nginx.conf 文件
主配置文件通常位于 /etc/nginx/nginx.conf,您可以在其中找到以下行:
text
include /etc/nginx/conf.d/.conf;
此行表示 nginx 将包含 /etc/nginx/conf.d 目录中的所有 .conf 文件。 这些文件通常包含虚拟主机配置、日志记录和代理设置等附加配置。
4. 查看 nginx.pid 文件
nginx.pid 文件包含 nginx 进程的进程 ID。 您可以使用以下命令获取该文件的内容:
bash
cat /var/run/nginx.pid
nginx.pid 文件将包含以下类似行:
text
12345 /etc/nginx/nginx.conf
其中 12345 是 nginx 进程的 PID,/etc/nginx/nginx.conf 是 nginx 使用的主配置文件。
5. 使用 ps 命令
bash
ps -ef | grep nginx
此命令将列出所有正在运行的 nginx 进程。 您可以在 "COMMAND" 列中看到 nginx 使用的配置文件路径。
示例输出:
text
nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf