如何检查验证 nginx.conf 配置是否正确

阿斌 2月前  服务器   410

最近新入了阿里云的VPS服务器,有三个网站需要迁移,LNMP的部署环境有所不同,需要对 Nginx 进行全新配置,经常需要检查 nginx.conf 文件配置是否正确,应该用什么方法?

2 个回答
  • 小何同志 2月前
    2
    不指定文件
    nginx -t
    [root@hqwaliyun2024 wwwroot]# nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    指定文件
    nginx -tc /etc/nginx/nginx.conf
    [root@hqwaliyun2024 wwwroot]# nginx -tc /etc/nginx/nginx.conf
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    2 回复引用 引用
  • 孤城浪人 2月前
    3
    楼上正解!另外,更改 nginx.conf 配置文件之后,利用 nginx -s reload 命令可以重新加载配置信息。此时如果配置有问题,似乎也会报错。
    1 回复引用 引用
    • 探知网
      4
        立即登录 立即注册
返回
发新帖