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

怎么知道nginx以哪个配置文件启动

  • nginx
  • 2024-05-04 03:52:18
  • 4342

1. 使用 nginx -t 命令验证 nginx 配置:
nginx -t -c /path/to/nginx.conf
2. 检查 nginx 进程的命令行参数:
使用以下命令获取 nginx 进程的命令行参数:
ps -ef | grep nginx
输出中将包含以下类似的行:
nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
其中 /etc/nginx/nginx.conf 是 nginx 使用的配置文件。
3. 检查 /proc/pid/cmdline 文件:
nginx 进程的命令行参数也可以在 /proc/pid/cmdline 中找到,其中 pid 是 nginx 进程的 PID:
cat /proc/pid/cmdline
4. 使用 nginx -V 命令查看运行时参数:
nginx -V 命令显示 nginx 的运行时参数,包括配置文件路径:
nginx -V
输出中将包含类似以下的行:
configure arguments: --pre fix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf
5. 使用 nginx -s reload 命令重新加载 nginx:
nginx -s reload 命令将重新加载 nginx 配置,而无需重新启动 nginx 服务。
重新加载后,使用上述方法之一检查新的配置文件路径。