参考资料

  1. Nginx作为反向代理的功能
  2. nginx配置文件详解
  3. Nginx基础安全设置及示例
  4. nginx 配置多个server
  5. 检测Nginx配置文件 nginx -t
  6. Nginx负载均衡策略详细说明以及案例
  7. Nginx的启动与停止命令
  8. 如何查看要查看 Nginx 默认配置文件路径

如何查看要查看 Nginx 默认配置文件路径

要查看 Nginx 默认配置文件路径,可以使用以下命令:

  1. 使用 nginx -t 命令测试配置文件并显示路径:

    nginx -t

    输出中会显示配置文件的路径,例如:

    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
  2. 使用 nginx -V 命令查看编译参数,其中包含配置文件路径:

    nginx -V

    输出中会显示 --conf-path 参数,例如:

    --conf-path=/etc/nginx/nginx.conf
  3. 默认情况下,Nginx 的配置文件通常位于以下路径之一:

    • /etc/nginx/nginx.conf

    • /usr/local/nginx/conf/nginx.conf

    • /usr/local/etc/nginx/nginx.conf

通过这些方法,你可以找到 Nginx 的默认配置文件路径。